Skip to content

034-week1_work #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Week_01/id_34/LeetCode_83_0.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
38 changes: 38 additions & 0 deletions Week_01/id_34/LeetCode_905_0.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}