摘要: Total Accepted: 92484Total Submissions: 288998Difficulty: MediumContributors: AdminSort a linked list using insertion sort.分析按照传统的插入方法,对list进行排序 56ms123456789101112131415161718192021222324252627282930... 阅读全文
posted @ 2017-02-14 22:36 copperface 阅读(216) 评论(0) 推荐(0) 编辑
摘要: Total Accepted: 83528Total Submissions: 314574Difficulty: HardContributors: AdminGiven a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume ... 阅读全文
posted @ 2017-02-14 21:46 copperface 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Total Accepted: 105470Total Submissions: 367141Difficulty: MediumContributors: AdminGiven a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return... 阅读全文
posted @ 2017-02-14 19:19 copperface 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list L: L0 → L1 → … → Ln-1 → Lnreorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → …Have you met this question in a real interview? YesExampleGiven 1->2->3->4->null, reorder it to 1... 阅读全文
posted @ 2017-02-14 16:52 copperface 阅读(232) 评论(0) 推荐(0) 编辑
摘要: Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order.Have you ... 阅读全文
posted @ 2017-02-14 15:59 copperface 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Insert a node in a sorted linked list.Have you met this question in a real interview? YesExampleGiven list = 1->4->6->8 and val = 5.Return 1->4->5->6->8.分析123456789101112131415161718192021222324252627... 阅读全文
posted @ 2017-02-14 15:54 copperface 阅读(265) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins.If there is no cycle, return null.Have you met this question in a real interview? YesExampleGiven -21->10->4->5, tail connects to node index... 阅读全文
posted @ 2017-02-14 15:43 copperface 阅读(218) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Have you met this question in a real interview? YesExampleGiven -21->10->4->5, tail connects to node index 1, return trueChallenge Follow up:Can ... 阅读全文
posted @ 2017-02-14 15:43 copperface 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Find the middle node of a linked list.ExampleGiven 1->2->3, return the node with value 2.Given 1->2, return the node with value 1.分析1 value 11->2 value11->2->3 value 21->2->3->4 value 21->2->3->4->5 v... 阅读全文
posted @ 2017-02-14 12:19 copperface 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. NoticeGiven m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list.ExampleGiven 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL.来... 阅读全文
posted @ 2017-02-14 12:17 copperface 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list.ExampleFor linked list 1->2->3, the reversed linked list is 3->2->1分析12345678910111213141516171819202122232425262728293031/** * Definition for ListNode. * public class ListNode {... 阅读全文
posted @ 2017-02-14 11:26 copperface 阅读(138) 评论(0) 推荐(0) 编辑
摘要: As the title described, you should only use two stacks to implement a queue's actions.The queue should support push(element), pop() and top() where pop is pop the first(a.k.a front) element in the que... 阅读全文
posted @ 2017-02-14 11:19 copperface 阅读(276) 评论(0) 推荐(0) 编辑
摘要: Implement a stack with min() function, which will return the smallest number in the stack.It should support push, pop and min operation all in O(1) cost. Noticemin operation will never be called if th... 阅读全文
posted @ 2017-02-14 11:08 copperface 阅读(204) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in an mx n matrix.This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row is gr... 阅读全文
posted @ 2017-02-14 10:22 copperface 阅读(203) 评论(0) 推荐(0) 编辑