File tree 5 files changed +52
-0
lines changed
5 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ All solutions will be accepted!
35
35
| 520| [ Detect Capital] ( https://leetcode-cn.com/problems/detect-capital/description/ ) | [ java/py/js] ( ./algorithms/DetectCaptial ) | Easy|
36
36
| 682| [ BaseBall Game] ( https://leetcode-cn.com/problems/baseball-game/description/ ) | [ java/py/js] ( ./algorithms/BaseBallGame ) | Easy|
37
37
| 404| [ Sum Of Left Leaves] ( https://leetcode-cn.com/problems/sum-of-left-leaves/description/ ) | [ java/py/js] ( ./algorithms/SumOfLeftLeaves ) | Easy|
38
+ | 283| [ Move Zeroes] ( https://leetcode-cn.com/problems/move-zeroes/description/ ) | [ java/py/js] ( ./algorithms/MoveZeroes ) | Easy|
38
39
39
40
# Database
40
41
| 596| [ Big Countries] ( https://leetcode-cn.com/problems/big-countries/description/ ) | [ mysql] ( ./database/BigCountries ) | Easy|
Original file line number Diff line number Diff line change
1
+ # Move Zeroes
2
+ This problem is easy to solve
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public void moveZeroes (int [] nums ) {
3
+ int length = nums .length ;
4
+ for (int i = 0 ; i < length ; i ++) {
5
+ if (nums [i ] != 0 ) continue ;
6
+ for (int j = i ; j < length ; j ++) {
7
+ if (nums [j ] != 0 ) {
8
+ nums [i ] = nums [i ] + nums [j ];
9
+ nums [j ] = nums [i ] - nums [j ];
10
+ nums [i ] = nums [i ] - nums [j ];
11
+ break ;
12
+ }
13
+ }
14
+ }
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } nums
3
+ * @return {void } Do not return anything, modify nums in-place instead.
4
+ */
5
+ var moveZeroes = function ( nums ) {
6
+ let length = nums . length
7
+ for ( let i = 0 ; i < length ; i ++ ) {
8
+ if ( nums [ i ] !== 0 ) continue
9
+ for ( let j = i ; j < length ; j ++ ) {
10
+ if ( nums [ j ] !== 0 ) {
11
+ nums [ i ] = nums [ i ] + nums [ j ]
12
+ nums [ j ] = nums [ i ] - nums [ j ]
13
+ nums [ i ] = nums [ i ] - nums [ j ]
14
+ break
15
+ }
16
+ }
17
+ }
18
+ } ;
Original file line number Diff line number Diff line change
1
+ class Solution (object ):
2
+ def moveZeroes (self , nums ):
3
+ """
4
+ :type nums: List[int]
5
+ :rtype: void Do not return anything, modify nums in-place instead.
6
+ """
7
+ length = len (nums )
8
+ for i in range (0 , length ):
9
+ if nums [i ] != 0 :
10
+ continue
11
+ for j in range (i , length ):
12
+ if nums [j ] != 0 :
13
+ nums [i ], nums [j ] = nums [j ], nums [i ]
14
+ break
15
+
You can’t perform that action at this time.
0 commit comments