| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3139b94 commit 55960f3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,20 @@ | |||
| 1 | + # Definition for singly-linked list. | ||
| 2 | + # class ListNode: | ||
| 3 | + # def __init__(self, x): | ||
| 4 | + # self.val = x | ||
| 5 | + # self.next = None | ||
| 6 | + | ||
| 7 | + class Solution: | ||
| 8 | + def deleteDuplicates(self, head: ListNode) -> ListNode: | ||
| 9 | + if not head: | ||
| 10 | + return head | ||
| 11 | + p = head | ||
| 12 | + q = head.next | ||
| 13 | + while q: | ||
| 14 | + if q.val != p.val: | ||
| 15 | + p.next = q | ||
| 16 | + p = p.next | ||
| 17 | + q = q.next | ||
| 18 | + if p!= q: | ||
| 19 | + p.next = None | ||
| 20 | + return head | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + class Solution: | ||
| 2 | + def sortArrayByParity(self, A: List[int]) -> List[int]: | ||
| 3 | + s1 = [] | ||
| 4 | + s2 = [] | ||
| 5 | + for a in A: | ||
| 6 | + if a %2 == 0: | ||
| 7 | + s1.append(a) | ||
| 8 | + else: | ||
| 9 | + s2.append(a) | ||
| 10 | + return s1 + s2 | ||
| 11 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments