上一页 1 2 3 4 5 6 7 8 ··· 19 下一页
摘要: 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) 编辑
摘要: Implement pow(x, n).分析该题目首先想到可以使用recursion去做,需要考虑一个陷阱,当 n 为 INT_MIN,反转会溢出1234567891011class Solution {public: double myPow(double x, int num) { long n = num; if(n == 0) return 1; ... 阅读全文
posted @ 2017-02-13 16:45 copperface 阅读(210) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 19 下一页