摘要: Find Peak Element:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple ... 阅读全文
posted @ 2016-01-26 20:33 Lewisr 阅读(122) 评论(0) 推荐(0)
摘要: Find Minimum in Rotated Sorted Array:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element. You may assume... 阅读全文
posted @ 2016-01-26 20:26 Lewisr 阅读(128) 评论(0) 推荐(0)
摘要: Sort Colors:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the i... 阅读全文
posted @ 2016-01-26 20:11 Lewisr 阅读(97) 评论(0) 推荐(0)
摘要: Container With Most Water:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i,... 阅读全文
posted @ 2016-01-26 19:58 Lewisr 阅读(119) 评论(0) 推荐(0)
摘要: 3Sum Closest:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would... 阅读全文
posted @ 2016-01-26 19:46 Lewisr 阅读(1221) 评论(0) 推荐(0)
摘要: Recorder List: Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it ... 阅读全文
posted @ 2016-01-18 19:16 Lewisr 阅读(200) 评论(0) 推荐(0)
摘要: Linked List Cycle II:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. 题意:对于给定的一个链表,判断其是否有环,如果有环的话,返回环开始的结点。 思路:在I中是判... 阅读全文
posted @ 2016-01-18 19:10 Lewisr 阅读(162) 评论(0) 推荐(0)
摘要: Reverse Linked List II: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n... 阅读全文
posted @ 2016-01-18 19:01 Lewisr 阅读(132) 评论(0) 推荐(0)
摘要: Remove Duplicates from Sorted List II:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2->3->3->4->4... 阅读全文
posted @ 2016-01-15 21:30 Lewisr 阅读(182) 评论(0) 推荐(0)
摘要: Insertion Sort List:Sort a linked list using insertion sort. 题意:使用插入排序的方式对链表进行排序。 思路:根据插入排序的思路,进行插入操作。 代码: public ListNode insertionSortList(ListNode head) { if(head==null||head.next==null) re... 阅读全文
posted @ 2016-01-15 21:21 Lewisr 阅读(147) 评论(0) 推荐(0)