Skip to content

Commit 3d7bfe7

Browse files
author
yuanxiao
committed
提交作业
1 parent 422070c commit 3d7bfe7

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+

Week_01/id_95/sortArrayByParity.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+

0 commit comments

Comments
 (0)