04 2015 档案

11. Container With Most Water
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ... 阅读全文

posted @ 2015-04-30 06:58 shini 阅读(118) 评论(0) 推荐(0)

8. String to Integer (atoi)
摘要:Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see below and ... 阅读全文

posted @ 2015-04-30 06:45 shini 阅读(105) 评论(0) 推荐(0)

9. Palindrome Number
摘要:Determine whether an integer is a palindrome. Do this without extra space.类似于reverse integer。public class Solution { public boolean isPalindrome(... 阅读全文

posted @ 2015-04-30 06:21 shini 阅读(107) 评论(0) 推荐(0)

7. Reverse Integer
摘要:Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321注意溢出,溢出返回0public class Solution { public int reverse(int x... 阅读全文

posted @ 2015-04-30 06:18 shini 阅读(130) 评论(0) 推荐(0)

5. Longest Palindromic Substring
摘要:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文

posted @ 2015-04-30 02:39 shini 阅读(83) 评论(0) 推荐(0)

128. Longest Consecutive Sequence
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest ... 阅读全文

posted @ 2015-04-30 00:36 shini 阅读(106) 评论(0) 推荐(0)

2. Add Two Numbers
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文

posted @ 2015-04-29 11:26 shini 阅读(99) 评论(0) 推荐(0)

205. Isomorphic Strings
摘要:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ... 阅读全文

posted @ 2015-04-29 11:14 shini 阅读(113) 评论(0) 推荐(0)

202. Happy Number
摘要:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer... 阅读全文

posted @ 2015-04-22 11:39 shini 阅读(124) 评论(0) 推荐(0)

141. Linked List Cycle
摘要:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Cracking Interview书上原题,快慢指针,如果有环肯定相遇。/** *... 阅读全文

posted @ 2015-04-18 08:14 shini 阅读(110) 评论(0) 推荐(0)

142. Linked List Cycle II
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?Cra... 阅读全文

posted @ 2015-04-18 08:11 shini 阅读(105) 评论(0) 推荐(0)

143. Reorder List
摘要:Given a singly linked listL: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 exam... 阅读全文

posted @ 2015-04-18 08:06 shini 阅读(87) 评论(0) 推荐(0)

94. Binary Tree Inorder Traversal
摘要:Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文

posted @ 2015-04-18 07:18 shini 阅读(93) 评论(0) 推荐(0)

144. Binary Tree Preorder Traversal
摘要:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].先pu... 阅读全文

posted @ 2015-04-18 06:55 shini 阅读(90) 评论(0) 推荐(0)

145. Binary Tree Postorder Traversal
摘要:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No... 阅读全文

posted @ 2015-04-18 06:39 shini 阅读(138) 评论(0) 推荐(0)

201. Bitwise AND of Numbers Range
摘要:Given a range [m, n] where 0 > 1; while (s != 0) { a |= s; s >>= 1; } return m&n&~a... 阅读全文

posted @ 2015-04-17 01:00 shini 阅读(138) 评论(0) 推荐(0)

146. LRU Cache
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu... 阅读全文

posted @ 2015-04-16 05:22 shini 阅读(159) 评论(0) 推荐(0)

148. Sort List
摘要:Sort a linked list inO(nlogn) time using constant space complexity.Merge Sort./** * Definition for singly-linked list. * class ListNode { * int ... 阅读全文

posted @ 2015-04-16 04:33 shini 阅读(84) 评论(0) 推荐(0)

150. Evaluate Reverse Polish Notation
摘要:Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文

posted @ 2015-04-15 02:53 shini 阅读(74) 评论(0) 推荐(0)

151. Reverse Words in a String
摘要:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Update (2015-02-12):For C prog... 阅读全文

posted @ 2015-04-15 02:42 shini 阅读(98) 评论(0) 推荐(0)

152. Maximum Product Subarray
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array[2,3,-2,4],the... 阅读全文

posted @ 2015-04-15 02:22 shini 阅读(110) 评论(0) 推荐(0)

153. 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 7might become4 5 6 7 0 1 2).Find the minimum element.You m... 阅读全文

posted @ 2015-04-15 02:03 shini 阅读(95) 评论(0) 推荐(0)

154. Find Minimum in Rotated Sorted Array II
摘要:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort... 阅读全文

posted @ 2015-04-15 02:01 shini 阅读(98) 评论(0) 推荐(0)

155. Min Stack
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes... 阅读全文

posted @ 2015-04-15 01:45 shini 阅读(126) 评论(0) 推荐(0)

160. Intersection of Two Linked Lists
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文

posted @ 2015-04-14 11:25 shini 阅读(106) 评论(0) 推荐(0)

162. Find Peak Element
摘要:A peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and return its index.... 阅读全文

posted @ 2015-04-14 11:09 shini 阅读(112) 评论(0) 推荐(0)

168. Excel Sheet Column Title
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ->... 阅读全文

posted @ 2015-04-13 08:37 shini 阅读(97) 评论(0) 推荐(0)

169. Majority Element
摘要:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume that the arr... 阅读全文

posted @ 2015-04-13 08:34 shini 阅读(219) 评论(0) 推荐(0)

171. Excel Sheet Column Number
摘要:Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A ... 阅读全文

posted @ 2015-04-13 08:26 shini 阅读(81) 评论(0) 推荐(0)

172. Factorial Trailing Zeroes
摘要:Given an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.cracking interview原题,2*5可以构成一... 阅读全文

posted @ 2015-04-13 08:24 shini 阅读(101) 评论(0) 推荐(0)

173. Binary Search Tree Iterator
摘要:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callingnext()will return the next... 阅读全文

posted @ 2015-04-09 11:57 shini 阅读(98) 评论(0) 推荐(0)

174. Dungeon Game
摘要:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a... 阅读全文

posted @ 2015-04-09 11:47 shini 阅读(132) 评论(0) 推荐(0)

179. Largest Number
摘要:Given a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the largest formed num... 阅读全文

posted @ 2015-04-09 11:38 shini 阅读(99) 评论(0) 推荐(0)

187. Repeated DNA Sequences
摘要:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to ... 阅读全文

posted @ 2015-04-09 11:29 shini 阅读(183) 评论(0) 推荐(0)

189. Rotate Array
摘要:Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].Note:Try to come... 阅读全文

posted @ 2015-04-08 07:37 shini 阅读(114) 评论(0) 推荐(0)

190. Reverse Bits
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ... 阅读全文

posted @ 2015-04-08 07:11 shini 阅读(104) 评论(0) 推荐(0)

191. Number of 1 Bits
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in... 阅读全文

posted @ 2015-04-08 07:04 shini 阅读(117) 评论(0) 推荐(0)

198. House Robber
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo... 阅读全文

posted @ 2015-04-08 06:59 shini 阅读(135) 评论(0) 推荐(0)

199. Binary Tree Right Side View
摘要:Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl... 阅读全文

posted @ 2015-04-08 06:51 shini 阅读(109) 评论(0) 推荐(0)

1. Two Sum
摘要:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文

posted @ 2015-04-07 11:53 shini 阅读(115) 评论(0) 推荐(0)

导航