摘要: Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],... 阅读全文
posted @ 2015-02-09 14:41 Vae永Silence 阅读(153) 评论(0) 推荐(0)
摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2015-02-09 14:40 Vae永Silence 阅读(142) 评论(0) 推荐(0)
摘要: Given a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18]./** * Definiti... 阅读全文
posted @ 2015-02-09 14:39 Vae永Silence 阅读(173) 评论(0) 推荐(0)
摘要: Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially... 阅读全文
posted @ 2015-02-09 14:38 Vae永Silence 阅读(205) 评论(0) 推荐(0)
摘要: Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe... 阅读全文
posted @ 2015-02-09 14:37 Vae永Silence 阅读(143) 评论(0) 推荐(0)
摘要: Given an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the following matri... 阅读全文
posted @ 2015-02-09 14:36 Vae永Silence 阅读(122) 评论(0) 推荐(0)
摘要: The set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie... 阅读全文
posted @ 2015-02-09 14:35 Vae永Silence 阅读(110) 评论(0) 推荐(0)
摘要: Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL./** *... 阅读全文
posted @ 2015-02-09 14:34 Vae永Silence 阅读(153) 评论(0) 推荐(0)
摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2015-02-09 14:33 Vae永Silence 阅读(138) 评论(0) 推荐(0)
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space i... 阅读全文
posted @ 2015-02-09 14:32 Vae永Silence 阅读(142) 评论(0) 推荐(0)
摘要: Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo... 阅读全文
posted @ 2015-02-09 14:31 Vae永Silence 阅读(106) 评论(0) 推荐(0)
摘要: Validate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the problem stat... 阅读全文
posted @ 2015-02-09 14:30 Vae永Silence 阅读(152) 评论(0) 推荐(0)
摘要: Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at... 阅读全文
posted @ 2015-02-09 14:29 Vae永Silence 阅读(115) 评论(0) 推荐(0)
摘要: Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".class Solution {public:string addBinary(string ... 阅读全文
posted @ 2015-02-09 14:28 Vae永Silence 阅读(122) 评论(0) 推荐(0)
摘要: Given an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) justified.You should p... 阅读全文
posted @ 2015-02-09 14:27 Vae永Silence 阅读(129) 评论(0) 推荐(0)
摘要: Implementint sqrt(int x).Compute and return the square root ofx.class Solution {public:int sqrt(int x){ long long left=0,right=x/2+1; while(left... 阅读全文
posted @ 2015-02-09 14:25 Vae永Silence 阅读(141) 评论(0) 推荐(0)
摘要: You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb... 阅读全文
posted @ 2015-02-09 14:24 Vae永Silence 阅读(118) 评论(0) 推荐(0)
摘要: Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas... 阅读全文
posted @ 2015-02-09 14:23 Vae永Silence 阅读(157) 评论(0) 推荐(0)
摘要: Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol... 阅读全文
posted @ 2015-02-09 14:22 Vae永Silence 阅读(188) 评论(0) 推荐(0)
摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A s... 阅读全文
posted @ 2015-02-09 14:21 Vae永Silence 阅读(131) 评论(0) 推荐(0)
摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
posted @ 2015-02-09 14:20 Vae永Silence 阅读(158) 评论(0) 推荐(0)
摘要: Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh... 阅读全文
posted @ 2015-02-09 14:19 Vae永Silence 阅读(191) 评论(0) 推荐(0)
摘要: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文
posted @ 2015-02-09 14:18 Vae永Silence 阅读(173) 评论(0) 推荐(0)
摘要: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2,3],... 阅读全文
posted @ 2015-02-09 14:17 Vae永Silence 阅读(157) 评论(0) 推荐(0)
摘要: Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co... 阅读全文
posted @ 2015-02-09 14:16 Vae永Silence 阅读(157) 评论(0) 推荐(0)
摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文
posted @ 2015-02-09 14:15 Vae永Silence 阅读(136) 评论(0) 推荐(0)
摘要: Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret... 阅读全文
posted @ 2015-02-09 14:14 Vae永Silence 阅读(119) 评论(0) 推荐(0)
摘要: Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2015-02-09 14:13 Vae永Silence 阅读(135) 评论(0) 推荐(0)
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2015-02-09 14:05 Vae永Silence 阅读(114) 评论(0) 推荐(0)
摘要: Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu... 阅读全文
posted @ 2015-02-09 14:03 Vae永Silence 阅读(145) 评论(0) 推荐(0)
摘要: Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文
posted @ 2015-02-09 14:02 Vae永Silence 阅读(207) 评论(0) 推荐(0)
摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.class Solution {public:int larges... 阅读全文
posted @ 2015-02-09 14:01 Vae永Silence 阅读(158) 评论(0) 推荐(0)
摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2015-02-09 14:00 Vae永Silence 阅读(185) 评论(0) 推荐(0)
摘要: Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation... 阅读全文
posted @ 2015-02-09 13:59 Vae永Silence 阅读(179) 评论(0) 推荐(0)
摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal... 阅读全文
posted @ 2015-02-09 13:58 Vae永Silence 阅读(141) 评论(0) 推荐(0)
摘要: The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number... 阅读全文
posted @ 2015-02-09 13:57 Vae永Silence 阅读(139) 评论(0) 推荐(0)
摘要: Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.... 阅读全文
posted @ 2015-02-09 13:56 Vae永Silence 阅读(154) 评论(0) 推荐(0)
摘要: A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta... 阅读全文
posted @ 2015-02-09 13:55 Vae永Silence 阅读(175) 评论(0) 推荐(0)
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2015-02-09 13:54 Vae永Silence 阅读(143) 评论(0) 推荐(0)
摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文
posted @ 2015-02-09 13:53 Vae永Silence 阅读(201) 评论(0) 推荐(0)
摘要: 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-02-09 13:52 Vae永Silence 阅读(124) 评论(0) 推荐(0)
摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文
posted @ 2015-02-09 13:51 Vae永Silence 阅读(175) 评论(0) 推荐(0)
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-02-09 13:50 Vae永Silence 阅读(173) 评论(0) 推荐(0)
摘要: Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens3="... 阅读全文
posted @ 2015-02-09 13:49 Vae永Silence 阅读(188) 评论(0) 推荐(0)
摘要: Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n... 阅读全文
posted @ 2015-02-09 13:48 Vae永Silence 阅读(133) 评论(0) 推荐(0)
摘要: Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文
posted @ 2015-02-09 13:47 Vae永Silence 阅读(177) 评论(0) 推荐(0)
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文
posted @ 2015-02-09 13:46 Vae永Silence 阅读(161) 评论(0) 推荐(0)
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2015-02-09 13:45 Vae永Silence 阅读(174) 评论(0) 推荐(0)
摘要: Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2015-02-09 13:43 Vae永Silence 阅读(168) 评论(0) 推荐(0)
摘要: Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-02-09 13:42 Vae永Silence 阅读(163) 评论(0) 推荐(0)
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2015-02-09 13:41 Vae永Silence 阅读(123) 评论(0) 推荐(0)
摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definitio... 阅读全文
posted @ 2015-02-09 13:40 Vae永Silence 阅读(243) 评论(0) 推荐(0)
摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree./** * Definiti... 阅读全文
posted @ 2015-02-09 13:39 Vae永Silence 阅读(186) 评论(0) 推荐(0)
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2015-02-09 13:37 Vae永Silence 阅读(187) 评论(0) 推荐(0)
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for binary tree * struct TreeNode { ... 阅读全文
posted @ 2015-02-09 13:36 Vae永Silence 阅读(136) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. ... 阅读全文
posted @ 2015-02-09 13:34 Vae永Silence 阅读(178) 评论(0) 推荐(0)
摘要: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2015-02-09 13:33 Vae永Silence 阅读(188) 评论(0) 推荐(0)
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2015-02-09 13:31 Vae永Silence 阅读(146) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2015-02-09 13:30 Vae永Silence 阅读(175) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2015-02-09 13:29 Vae永Silence 阅读(177) 评论(0) 推荐(0)
摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文
posted @ 2015-02-09 13:28 Vae永Silence 阅读(184) 评论(0) 推荐(0)
摘要: Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig... 阅读全文
posted @ 2015-02-09 13:26 Vae永Silence 阅读(153) 评论(0) 推荐(0)
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2015-02-09 13:25 Vae永Silence 阅读(153) 评论(0) 推荐(0)
摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2015-02-09 13:23 Vae永Silence 阅读(173) 评论(0) 推荐(0)
摘要: GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]... 阅读全文
posted @ 2015-02-09 13:22 Vae永Silence 阅读(168) 评论(0) 推荐(0)
摘要: Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(... 阅读全文
posted @ 2015-02-09 13:20 Vae永Silence 阅读(114) 评论(0) 推荐(0)
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol... 阅读全文
posted @ 2015-02-09 13:19 Vae永Silence 阅读(128) 评论(0) 推荐(0)
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文
posted @ 2015-02-09 13:18 Vae永Silence 阅读(120) 评论(0) 推荐(0)
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2015-02-09 13:16 Vae永Silence 阅读(123) 评论(0) 推荐(0)
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2015-02-09 13:15 Vae永Silence 阅读(141) 评论(0) 推荐(0)
摘要: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ... 阅读全文
posted @ 2015-02-09 13:14 Vae永Silence 阅读(122) 评论(0) 推荐(0)
摘要: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana... 阅读全文
posted @ 2015-02-09 13:13 Vae永Silence 阅读(145) 评论(0) 推荐(0)
摘要: Given two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter can be changed... 阅读全文
posted @ 2015-02-09 13:11 Vae永Silence 阅读(182) 评论(0) 推荐(0)
摘要: Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文
posted @ 2015-02-09 13:10 Vae永Silence 阅读(246) 评论(0) 推荐(0)
摘要: 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-02-09 13:07 Vae永Silence 阅读(168) 评论(0) 推荐(0)
摘要: Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep... 阅读全文
posted @ 2015-02-09 13:06 Vae永Silence 阅读(200) 评论(0) 推荐(0)
摘要: Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region... 阅读全文
posted @ 2015-02-09 13:04 Vae永Silence 阅读(168) 评论(0) 推荐(0)
摘要: Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv... 阅读全文
posted @ 2015-02-09 13:03 Vae永Silence 阅读(163) 评论(0) 推荐(0)
摘要: Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs... 阅读全文
posted @ 2015-02-09 13:01 Vae永Silence 阅读(139) 评论(0) 推荐(0)
摘要: Clone an undirected graph. Each node in the graph contains alabeland a list of itsneighbors.OJ's undirected graph serialization:Nodes are labeled uniq... 阅读全文
posted @ 2015-02-09 13:00 Vae永Silence 阅读(224) 评论(0) 推荐(0)
摘要: There areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it costscost[... 阅读全文
posted @ 2015-02-09 12:58 Vae永Silence 阅读(160) 评论(0) 推荐(0)
摘要: There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requi... 阅读全文
posted @ 2015-02-09 12:57 Vae永Silence 阅读(130) 评论(0) 推荐(0)
摘要: Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2015-02-09 12:55 Vae永Silence 阅读(137) 评论(0) 推荐(0)
摘要: Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2015-02-09 12:54 Vae永Silence 阅读(157) 评论(0) 推荐(0)
摘要: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ... 阅读全文
posted @ 2015-02-09 12:52 Vae永Silence 阅读(138) 评论(0) 推荐(0)
摘要: Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.For exampl... 阅读全文
posted @ 2015-02-09 12:50 Vae永Silence 阅读(149) 评论(0) 推荐(0)
摘要: Given a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all such possibl... 阅读全文
posted @ 2015-02-09 12:49 Vae永Silence 阅读(161) 评论(0) 推荐(0)
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. *... 阅读全文
posted @ 2015-02-09 12:47 Vae永Silence 阅读(134) 评论(0) 推荐(0)
摘要: 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?/**... 阅读全文
posted @ 2015-02-09 12:46 Vae永Silence 阅读(116) 评论(0) 推荐(0)
摘要: 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-02-09 12:44 Vae永Silence 阅读(134) 评论(0) 推荐(0)
摘要: Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].Not... 阅读全文
posted @ 2015-02-09 12:43 Vae永Silence 阅读(128) 评论(0) 推荐(0)
摘要: 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-02-09 12:40 Vae永Silence 阅读(162) 评论(0) 推荐(0)
摘要: 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-02-09 12:39 Vae永Silence 阅读(136) 评论(0) 推荐(0)
摘要: Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNo... 阅读全文
posted @ 2015-02-09 12:37 Vae永Silence 阅读(147) 评论(0) 推荐(0)
摘要: Sort a linked list inO(nlogn) time using constant space complexity./** * Definition for singly-linked list. * struct ListNode { * int val; * L... 阅读全文
posted @ 2015-02-09 00:25 Vae永Silence 阅读(135) 评论(0) 推荐(0)
摘要: Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line./** * Definition for a point. * struct Point { * ... 阅读全文
posted @ 2015-02-09 00:09 Vae永Silence 阅读(180) 评论(0) 推荐(0)
摘要: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2015-02-09 00:07 Vae永Silence 阅读(150) 评论(0) 推荐(0)
摘要: Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Cl... 阅读全文
posted @ 2015-02-09 00:06 Vae永Silence 阅读(165) 评论(0) 推荐(0)
摘要: 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-02-09 00:04 Vae永Silence 阅读(106) 评论(0) 推荐(0)
摘要: 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-02-09 00:02 Vae永Silence 阅读(100) 评论(0) 推荐(0)