摘要: Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3. 1 public static LinkedListNode RemoveDuplicatesfromSortedList(LinkedListNode head) 2 { 3 if (head == null . 阅读全文
posted @ 2012-10-11 23:46 ETCOW 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,2,3]. 1 public static int RemoveDuplicatesfromSortedArrayII(int[] A) 2 { 3 int prev ... 阅读全文
posted @ 2012-10-11 23:41 ETCOW 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given input array A = [1,1,2],Your function should return length = 2, and A 阅读全文
posted @ 2012-10-11 23:37 ETCOW 阅读(303) 评论(0) 推荐(0) 编辑