From 651a8c619383a53069650e135309f43c8e30a9fc Mon Sep 17 00:00:00 2001 From: hotboy <2152160@gmail.com> Date: Fri, 19 Apr 2019 23:22:54 +0800 Subject: [PATCH 1/2] Create LeetCode_83_0.cs --- Week_01/id_34/LeetCode_83_0.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Week_01/id_34/LeetCode_83_0.cs diff --git a/Week_01/id_34/LeetCode_83_0.cs b/Week_01/id_34/LeetCode_83_0.cs new file mode 100644 index 00000000..fa2286c4 --- /dev/null +++ b/Week_01/id_34/LeetCode_83_0.cs @@ -0,0 +1,29 @@ + public class Solution + { + public ListNode DeleteDuplicates(ListNode head) + { + int currentValue = head.val; + int nextValue = 0; + + + if(head == null|| head.next==null) + { return head; } + + ListNode copyHead = head; + while(copyHead.next!=null) + { + currentValue = copyHead.val; + nextValue = copyHead.next.val; + if(currentValue==nextValue) + { + copyHead.next = copyHead.next.next; + } + else + { + copyHead = copyHead.next; + } + } + + return head; + } + } From 9309e456bb9463ef7e70a2114411fe01c68789f1 Mon Sep 17 00:00:00 2001 From: hotboy <2152160@gmail.com> Date: Fri, 19 Apr 2019 23:27:24 +0800 Subject: [PATCH 2/2] Create LeetCode_905_0.cs --- Week_01/id_34/LeetCode_905_0.cs | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Week_01/id_34/LeetCode_905_0.cs diff --git a/Week_01/id_34/LeetCode_905_0.cs b/Week_01/id_34/LeetCode_905_0.cs new file mode 100644 index 00000000..2ca32675 --- /dev/null +++ b/Week_01/id_34/LeetCode_905_0.cs @@ -0,0 +1,38 @@ + public class Solution + { + public int[] SortArrayByParity(int[] A) + { + if (A == null && A.Length == 0) + { + return A; + } + int indexHead = 0; + int indexTail = A.Length - 1; + int tempValue = 0; + while (indexHead < indexTail) + { + if (A[indexHead] % 2 == 1 && A[indexTail] % 2 == 0) + { + tempValue = A[indexHead]; + A[indexHead] = A[indexTail]; + A[indexTail] = tempValue; + indexHead++; + indexTail--; + } + else if (A[indexHead] % 2 == 0 && A[indexTail] % 2 == 1) + { + indexHead++; + indexTail--; + } + else if (A[indexHead] % 2 == 1) + { + indexTail--; + } + else if (A[indexTail] % 2 == 0) + { + indexHead++; + } + } + return A; + } + }