File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Definition for singly-linked list.
2
+ class ListNode (object ):
3
+
4
+ def __init__ (self , x ):
5
+ self .val = x
6
+ self .next = None
7
+
8
+
9
+ class Solution (object ):
10
+
11
+ def deleteDuplicates (self , head ):
12
+
13
+ current = head
14
+ if current is None :
15
+ return head
16
+ while current .next is not None :
17
+ if current .val == current .next .val :
18
+ if current .next .next is not None :
19
+ current .next = current .next .next
20
+ # current = current.next
21
+ else :
22
+ current .next = None
23
+ else :
24
+ current = current .next
25
+ return head
26
+
27
+
Original file line number Diff line number Diff line change
1
+ class Solution (object ):
2
+ def sortArrayByParity (self , A ):
3
+ left = 0
4
+ right = len (A )- 1
5
+ middle = int ((right + left )/ 2 )
6
+ print ("中间值" ,middle )
7
+ while (left < right ):
8
+
9
+ if (A [left ]% 2 ) == 0 :
10
+ left += 1
11
+ elif (A [left ]% 2 ) != 0 :
12
+
13
+ tmp = A [right ]
14
+ A [right ] = A [left ]
15
+ A [left ] = tmp
16
+
17
+ right = right - 1
18
+ # left = left + 1
19
+ return A
20
+
21
+
22
+
23
+ if __name__ == "__main__" :
24
+ A = [1 ,0 ,3 ]
25
+ array = Solution ()
26
+ print (array .sortArrayByParity (A ))
27
+
28
+
29
+
30
+
31
+
32
+
You can’t perform that action at this time.
0 commit comments