摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted in asc... 阅读全文
posted @ 2015-08-08 23:36 ~每天进步一点点~ 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Given an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers ... 阅读全文
posted @ 2015-08-08 20:51 ~每天进步一点点~ 阅读(194) 评论(0) 推荐(0) 编辑
摘要: Given an array ofnintegers wheren> 1,nums, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Solv... 阅读全文
posted @ 2015-08-08 20:13 ~每天进步一点点~ 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is1 -> 2 -> 3 -> ... 阅读全文
posted @ 2015-08-08 19:48 ~每天进步一点点~ 阅读(105) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest ... 阅读全文
posted @ 2015-08-08 19:41 ~每天进步一点点~ 阅读(213) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文
posted @ 2015-08-08 18:34 ~每天进步一点点~ 阅读(239) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?/** * Definition for singly-linked l... 阅读全文
posted @ 2015-08-08 18:04 ~每天进步一点点~ 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6... 阅读全文
posted @ 2015-08-08 17:32 ~每天进步一点点~ 阅读(103) 评论(0) 推荐(1) 编辑
摘要: Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o... 阅读全文
posted @ 2015-08-08 16:55 ~每天进步一点点~ 阅读(112) 评论(0) 推荐(0) 编辑
摘要: Given an integer, write a function to determine if it is a power of two.public class Solution { //注意0和负数都返回false!!! /*public boolean isP... 阅读全文
posted @ 2015-08-08 16:38 ~每天进步一点点~ 阅读(179) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's tota... 阅读全文
posted @ 2015-08-08 16:15 ~每天进步一点点~ 阅读(97) 评论(0) 推荐(0) 编辑
摘要: Given an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times. The algorithm should run in linear time and in O(1) space.public... 阅读全文
posted @ 2015-08-08 15:54 ~每天进步一点点~ 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].public cl... 阅读全文
posted @ 2015-08-08 15:16 ~每天进步一点点~ 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Implement a basic calculator to evaluate a simple expression string.The expression string contains onlynon-negativeintegers,+,-,*,/operators and empty... 阅读全文
posted @ 2015-08-08 14:54 ~每天进步一点点~ 阅读(479) 评论(0) 推荐(0) 编辑
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/** * Definition for a binary tree node... 阅读全文
posted @ 2015-08-08 14:16 ~每天进步一点点~ 阅读(86) 评论(0) 推荐(0) 编辑
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2015-08-08 14:04 ~每天进步一点点~ 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Implement a basic calculator to evaluate a simple expression string.The expression string may contain open(and closing parentheses), the plus+or minus... 阅读全文
posted @ 2015-08-08 13:17 ~每天进步一点点~ 阅读(203) 评论(0) 推荐(0) 编辑