摘要: Sort a linked list using insertion sort. 链表的插入排序 思路,递归到链表尾,然后循环插入; 阅读全文
posted @ 2017-11-03 06:42 SkyMelody 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 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, 阅读全文
posted @ 2017-11-02 13:50 SkyMelody 阅读(73) 评论(0) 推荐(0) 编辑
摘要: Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文
posted @ 2017-11-01 21:44 SkyMelody 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 思路:快慢指针,设置一个走两步的快指针,和一个走一步的慢指针,如果有环,则它们一 阅读全文
posted @ 2017-11-01 12:50 SkyMelody 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 思路:既然数组里的元素已经按升序排好序了,那么不难想到用二分法来做这道题。 /** * Definiti 阅读全文
posted @ 2017-10-29 13:25 SkyMelody 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文
posted @ 2017-10-29 11:25 SkyMelody 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array of integers, find the length of longest continuous increasing subsequence. Example 1: Example 2: Note: Length of the array wil 阅读全文
posted @ 2017-10-27 16:04 SkyMelody 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length 阅读全文
posted @ 2017-10-27 13:09 SkyMelody 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin 阅读全文
posted @ 2017-10-27 09:56 SkyMelody 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Inp 阅读全文
posted @ 2017-10-26 22:55 SkyMelody 阅读(112) 评论(0) 推荐(0) 编辑