Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 18 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 12, 2022
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8030165
添加 515.在每个树行中找最大值 Scala版本
wzqwtt May 19, 2022
a317949
添加 116.填充每个节点的下一个右侧节点指针 Scala版本
wzqwtt May 19, 2022
7a62a75
添加 117.填充每个节点的下一个右侧节点指针II Scala版本
wzqwtt May 19, 2022
32f0599
添加 104.二叉树的最大深度 Scala版本
wzqwtt May 19, 2022
f5c5a58
添加 111.二叉树的最小深度 Scala版本
wzqwtt May 19, 2022
afcf6cd
添加(0718.最长重复子数组.md):增加typescript版本
xiaofei-2020 May 19, 2022
a4b0247
添加0704.二分查找 Kotlin版本
Mrxulovemingming May 19, 2022
6177934
Merge branch 'youngyangyang04:master' into master
Mrxulovemingming May 21, 2022
3de2992
添加0027.移除元素 Kotlin版本
Mrxulovemingming May 21, 2022
b57842d
Merge branch 'youngyangyang04:master' into master
Mrxulovemingming May 22, 2022
10b440e
添加0977.有序数组的平方 Kotlin版本
Mrxulovemingming May 23, 2022
35666ef
Merge branch 'youngyangyang04:master' into master
Mrxulovemingming May 25, 2022
2b434d0
Merge branch 'master' into master
Mrxulovemingming May 28, 2022
770c230
Merge pull request #1353 from wzqwtt/tree04
youngyangyang04 Jun 11, 2022
8156c35
Merge pull request #1354 from wzqwtt/tree05
youngyangyang04 Jun 11, 2022
0ffffe0
Merge pull request #1355 from xiaofei-2020/dp43
youngyangyang04 Jun 11, 2022
b37c3e0
Merge branch 'master' into master
youngyangyang04 Jun 11, 2022
a6ce79a
Merge pull request #1357 from Mrxulovemingming/master
youngyangyang04 Jun 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into master
  • Loading branch information
commit 2b434d0e462e1c27727e6fc1d6fedcb99a477756
38 changes: 37 additions & 1 deletion problems/0977.有序数组的平方.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ class Solution {
}
}
```
Scala:

Kotlin:
```kotlin
Expand All @@ -383,5 +382,42 @@ class Solution {
}
```

Scala:

双指针:
```scala
object Solution {
def sortedSquares(nums: Array[Int]): Array[Int] = {
val res: Array[Int] = new Array[Int](nums.length)
var top = nums.length - 1
var i = 0
var j = nums.length - 1
while (i <= j) {
if (nums(i) * nums(i) <= nums(j) * nums(j)) {
// 当左侧平方小于等于右侧,res数组顶部放右侧的平方,并且top下移,j左移
res(top) = nums(j) * nums(j)
top -= 1
j -= 1
} else {
// 当左侧平方大于右侧,res数组顶部放左侧的平方,并且top下移,i右移
res(top) = nums(i) * nums(i)
top -= 1
i += 1
}
}
res
}
}
```
骚操作(暴力思路):
```scala
object Solution {
def sortedSquares(nums: Array[Int]): Array[Int] = {
nums.map(x=>{x*x}).sortWith(_ < _)
}
}
```


-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>
You are viewing a condensed version of this merge commit. You can view the full changes here.

AltStyle によって変換されたページ (->オリジナル) /