04 2015 档案

摘要:题目: Given a singly linked list L: 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. 阅读全文
posted @ 2015-04-19 12:37 YRB 阅读(527) 评论(0) 推荐(0)
摘要:题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra spa 阅读全文
posted @ 2015-04-19 11:23 YRB 阅读(498) 评论(0) 推荐(0)
摘要:题目: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 链接: http://leetcode.com/problems/lin 阅读全文
posted @ 2015-04-19 11:22 YRB 阅读(890) 评论(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 poss... 阅读全文
posted @ 2015-04-19 11:21 YRB 阅读(1671) 评论(0) 推荐(0)
摘要:题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. 阅读全文
posted @ 2015-04-19 11:19 YRB 阅读(1539) 评论(1) 推荐(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 co... 阅读全文
posted @ 2015-04-19 11:18 YRB 阅读(440) 评论(1) 推荐(0)
摘要:题目: Given an array of integers, every element appears three times except for one. Find that single one. Note:Your algorithm should have a linear runti 阅读全文
posted @ 2015-04-19 11:15 YRB 阅读(509) 评论(0) 推荐(0)
摘要:题目: Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime com 阅读全文
posted @ 2015-04-19 11:07 YRB 阅读(227) 评论(0) 推荐(0)
摘要:题目: There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the followin 阅读全文
posted @ 2015-04-19 11:05 YRB 阅读(392) 评论(0) 推荐(0)
摘要:题目: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it 阅读全文
posted @ 2015-04-19 11:03 YRB 阅读(429) 评论(0) 推荐(0)
摘要:题目: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are lab 阅读全文
posted @ 2015-04-19 11:01 YRB 阅读(1275) 评论(0) 推荐(0)
摘要:题目:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ... 阅读全文
posted @ 2015-04-19 10:56 YRB 阅读(841) 评论(0) 推荐(0)
摘要:题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For ex 阅读全文
posted @ 2015-04-19 10:55 YRB 阅读(1245) 评论(1) 推荐(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 surrou 阅读全文
posted @ 2015-04-19 10:53 YRB 阅读(526) 评论(0) 推荐(0)
摘要:题目: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 阅读全文
posted @ 2015-04-19 10:43 YRB 阅读(758) 评论(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 lo 阅读全文
posted @ 2015-04-19 10:42 YRB 阅读(365) 评论(0) 推荐(0)
摘要:题目: Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWo 阅读全文
posted @ 2015-04-19 00:39 YRB 阅读(2046) 评论(2) 推荐(0)
摘要:题目:Given two words (beginWordandendWord), and a dictionary's word list, find all shortest transformation sequence(s) frombeginWordtoendWord, such that... 阅读全文
posted @ 2015-04-19 00:37 YRB 阅读(823) 评论(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: 阅读全文
posted @ 2015-04-19 00:34 YRB 阅读(419) 评论(0) 推荐(0)
摘要:题目:Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in ... 阅读全文
posted @ 2015-04-19 00:33 YRB 阅读(918) 评论(0) 推荐(0)
摘要:题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may co 阅读全文
posted @ 2015-04-19 00:28 YRB 阅读(769) 评论(0) 推荐(0)
摘要:题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may co 阅读全文
posted @ 2015-04-19 00:27 YRB 阅读(362) 评论(0) 推荐(0)
摘要:题目: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transac 阅读全文
posted @ 2015-04-19 00:14 YRB 阅读(390) 评论(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 th 阅读全文
posted @ 2015-04-19 00:13 YRB 阅读(403) 评论(0) 推荐(0)
摘要:题目: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. 链接: http://leetcode.com/problems/pascals 阅读全文
posted @ 2015-04-19 00:11 YRB 阅读(450) 评论(0) 推荐(0)
摘要:题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1 阅读全文
posted @ 2015-04-19 00:10 YRB 阅读(622) 评论(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 阅读全文
posted @ 2015-04-18 15:19 YRB 阅读(1159) 评论(0) 推荐(0)
摘要:题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to it 阅读全文
posted @ 2015-04-18 14:03 YRB 阅读(1242) 评论(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 o... 阅读全文
posted @ 2015-04-18 14:02 YRB 阅读(306) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: click to show hints. Hints: If y 阅读全文
posted @ 2015-04-18 14:01 YRB 阅读(678) 评论(0) 推荐(0)
摘要:题目: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. return 链接: http://leetcode.com/problems/pat 阅读全文
posted @ 2015-04-18 13:59 YRB 阅读(610) 评论(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 su 阅读全文
posted @ 2015-04-18 13:58 YRB 阅读(697) 评论(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 neare 阅读全文
posted @ 2015-04-18 13:57 YRB 阅读(1277) 评论(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 阅读全文
posted @ 2015-04-18 13:56 YRB 阅读(769) 评论(0) 推荐(0)
摘要:题目: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 链接: http://leetcode.com/problems/con 阅读全文
posted @ 2015-04-18 13:54 YRB 阅读(1366) 评论(0) 推荐(0)
摘要:题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 链接: http://leetcode.com/problems/convert-sorted- 阅读全文
posted @ 2015-04-18 13:51 YRB 阅读(1080) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 阅读全文
posted @ 2015-04-18 13:47 YRB 阅读(559) 评论(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. 链接: http 阅读全文
posted @ 2015-04-18 13:46 YRB 阅读(599) 评论(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. 链接: http: 阅读全文
posted @ 2015-04-18 13:41 YRB 阅读(612) 评论(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 farthe 阅读全文
posted @ 2015-04-18 13:40 YRB 阅读(903) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level 阅读全文
posted @ 2015-04-18 13:39 YRB 阅读(437) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tre 阅读全文
posted @ 2015-04-18 13:38 YRB 阅读(420) 评论(0) 推荐(1)
摘要:题目: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But the 阅读全文
posted @ 2015-04-18 12:24 YRB 阅读(405) 评论(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 identic 阅读全文
posted @ 2015-04-18 12:23 YRB 阅读(367) 评论(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 ... 阅读全文
posted @ 2015-04-18 12:22 YRB 阅读(632) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: 链接:http://leetcode.com/problems/vali 阅读全文
posted @ 2015-04-18 12:21 YRB 阅读(1098) 评论(0) 推荐(0)
摘要:题目:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens... 阅读全文
posted @ 2015-04-18 12:20 YRB 阅读(432) 评论(0) 推荐(0)
摘要:题目: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique 阅读全文
posted @ 2015-04-18 12:19 YRB 阅读(404) 评论(0) 推荐(0)
摘要:题目: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should return 阅读全文
posted @ 2015-04-18 12:17 YRB 阅读(877) 评论(0) 推荐(0)
摘要:题目: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,3,2]. 链接: http://leetco 阅读全文
posted @ 2015-04-18 12:16 YRB 阅读(530) 评论(0) 推荐(0)
摘要:题目: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return 阅读全文
posted @ 2015-04-18 12:15 YRB 阅读(851) 评论(0) 推荐(0)
摘要:题目: Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3 阅读全文
posted @ 2015-04-18 12:13 YRB 阅读(552) 评论(0) 推荐(0)
摘要:题目: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded me 阅读全文
posted @ 2015-04-18 12:11 YRB 阅读(629) 评论(1) 推荐(0)
摘要:题目: Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: Elements in a subset must be in non-descend 阅读全文
posted @ 2015-04-18 12:10 YRB 阅读(738) 评论(0) 推荐(0)
摘要:题目: The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total 阅读全文
posted @ 2015-04-18 12:09 YRB 阅读(530) 评论(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 阅读全文
posted @ 2015-04-18 12:08 YRB 阅读(343) 评论(0) 推荐(0)
摘要:题目: Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible represen 阅读全文
posted @ 2015-04-18 12:07 YRB 阅读(628) 评论(0) 推荐(0)
摘要:题目: Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve 阅读全文
posted @ 2015-04-18 12:06 YRB 阅读(357) 评论(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. 链接: http://leetcode.com/prob 阅读全文
posted @ 2015-04-18 12:05 YRB 阅读(738) 评论(0) 推荐(0)
摘要:题目: Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the 阅读全文
posted @ 2015-04-18 12:04 YRB 阅读(543) 评论(0) 推荐(0)
摘要:题目: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3 阅读全文
posted @ 2015-04-18 12:03 YRB 阅读(205) 评论(0) 推荐(0)
摘要:题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given  阅读全文
posted @ 2015-04-18 12:02 YRB 阅读(232) 评论(0) 推荐(0)
摘要:题目: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a fun 阅读全文
posted @ 2015-04-18 12:01 YRB 阅读(305) 评论(0) 推荐(0)
摘要:题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function 阅读全文
posted @ 2015-04-18 12:00 YRB 阅读(273) 评论(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 "a 阅读全文
posted @ 2015-04-18 11:59 YRB 阅读(1650) 评论(0) 推荐(1)
摘要:题目: 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 mus 阅读全文
posted @ 2015-04-18 11:58 YRB 阅读(751) 评论(0) 推荐(0)
摘要:题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: [ [2,4], 阅读全文
posted @ 2015-04-18 11:57 YRB 阅读(1090) 评论(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 = "ADOB 阅读全文
posted @ 2015-04-18 11:55 YRB 阅读(366) 评论(0) 推荐(0)
摘要:题目: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r 阅读全文
posted @ 2015-04-18 11:54 YRB 阅读(313) 评论(0) 推荐(0)
摘要:题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sort 阅读全文
posted @ 2015-04-18 11:53 YRB 阅读(219) 评论(0) 推荐(0)
摘要:题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 链接: http://leetcode.com/problems/set-matrix-zeroes/ 阅读全文
posted @ 2015-04-18 11:52 YRB 阅读(328) 评论(0) 推荐(0)
摘要:题目: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You h 阅读全文
posted @ 2015-04-18 11:50 YRB 阅读(474) 评论(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 sho 阅读全文
posted @ 2015-04-18 11:49 YRB 阅读(325) 评论(0) 推荐(0)
摘要:题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can yo 阅读全文
posted @ 2015-04-18 00:17 YRB 阅读(299) 评论(0) 推荐(0)
摘要:题目: Implement int sqrt(int x). Compute and return the square root of x. 链接: http://leetcode.com/problems/sqrtx/ 题解: 求平方根。 二分法, Time Complexity - O(log 阅读全文
posted @ 2015-04-18 00:12 YRB 阅读(541) 评论(0) 推荐(0)
摘要:题目: Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You 阅读全文
posted @ 2015-04-18 00:09 YRB 阅读(451) 评论(0) 推荐(0)
摘要:题目: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 链接: http://leetcode.com/problems/add-b 阅读全文
posted @ 2015-04-18 00:08 YRB 阅读(408) 评论(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 阅读全文
posted @ 2015-04-18 00:07 YRB 阅读(298) 评论(0) 推荐(0)
摘要:题目: Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended for 阅读全文
posted @ 2015-04-17 23:58 YRB 阅读(524) 评论(0) 推荐(0)
摘要:题目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its pa 阅读全文
posted @ 2015-04-17 23:57 YRB 阅读(289) 评论(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 s 阅读全文
posted @ 2015-04-17 23:54 YRB 阅读(305) 评论(0) 推荐(0)
摘要:题目: A robot is located at the top-left corner of a m x ngrid (marked 'Start' in the diagram below). The robot can only move either down or right at an 阅读全文
posted @ 2015-04-17 23:53 YRB 阅读(349) 评论(0) 推荐(0)
摘要:题目: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2 阅读全文
posted @ 2015-04-17 23:50 YRB 阅读(270) 评论(0) 推荐(0)
摘要:题目: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequ 阅读全文
posted @ 2015-04-17 23:49 YRB 阅读(668) 评论(0) 推荐(0)
摘要:题目: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3, You should return the fol 阅读全文
posted @ 2015-04-17 23:47 YRB 阅读(284) 评论(0) 推荐(0)
摘要:题目: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last 阅读全文
posted @ 2015-04-17 23:45 YRB 阅读(178) 评论(0) 推荐(0)
摘要:题目: Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were in 阅读全文
posted @ 2015-04-17 23:44 YRB 阅读(493) 评论(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]. Given 阅读全文
posted @ 2015-04-17 23:42 YRB 阅读(649) 评论(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 m 阅读全文
posted @ 2015-04-17 23:41 YRB 阅读(332) 评论(0) 推荐(0)
摘要:题目: Given a matrix of m x n elements (m rows, ncolumns), return all elements of the matrix in spiral order. For example,Given the following matrix: Yo 阅读全文
posted @ 2015-04-17 23:40 YRB 阅读(476) 评论(0) 推荐(0)
摘要:题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,− 阅读全文
posted @ 2015-04-17 23:39 YRB 阅读(778) 评论(0) 推荐(0)
摘要:题目: Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. Show Tags Show Simila 阅读全文
posted @ 2015-04-17 23:38 YRB 阅读(436) 评论(0) 推荐(0)
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return 阅读全文
posted @ 2015-04-17 23:37 YRB 阅读(725) 评论(0) 推荐(0)
摘要:题目: Implement pow(x, n). 链接: http://leetcode.com/problems/powx-n/ 题解: 使用二分法求实数幂,假如不建立临时变量halfPow,直接return计算结果的话会超时,还没仔细研究为什么。 Time Complexity - O(logn 阅读全文
posted @ 2015-04-17 23:36 YRB 阅读(468) 评论(0) 推荐(0)
摘要:题目: Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. Hide Tags Hash Table String Giv 阅读全文
posted @ 2015-04-17 23:32 YRB 阅读(346) 评论(0) 推荐(0)
摘要:题目: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 链接: http 阅读全文
posted @ 2015-04-17 23:31 YRB 阅读(489) 评论(0) 推荐(0)
摘要:题目: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following uniqu 阅读全文
posted @ 2015-04-17 23:30 YRB 阅读(569) 评论(0) 推荐(0)
摘要:题目: Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2 阅读全文
posted @ 2015-04-17 23:28 YRB 阅读(1521) 评论(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 m 阅读全文
posted @ 2015-04-17 23:25 YRB 阅读(393) 评论(0) 推荐(0)
摘要:题目: Implement wildcard pattern matching with support for '?' and '*'. 链接: http://leetcode.com/problems/wildcard-matching/ 题解: 这道题是一刷里放弃的6道题中第一道。看过<挑战程 阅读全文
posted @ 2015-04-17 23:24 YRB 阅读(812) 评论(0) 推荐(0)
摘要:题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non 阅读全文
posted @ 2015-04-17 23:23 YRB 阅读(863) 评论(0) 推荐(0)
摘要:题目: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rain 阅读全文
posted @ 2015-04-17 23:22 YRB 阅读(413) 评论(0) 推荐(0)
摘要:题目: Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorit 阅读全文
posted @ 2015-04-17 23:20 YRB 阅读(302) 评论(0) 推荐(0)
摘要:题目: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each 阅读全文
posted @ 2015-04-17 23:19 YRB 阅读(459) 评论(0) 推荐(0)
摘要:题目: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same re 阅读全文
posted @ 2015-04-17 23:18 YRB 阅读(1741) 评论(0) 推荐(0)
摘要:题目: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read 阅读全文
posted @ 2015-04-17 23:16 YRB 阅读(567) 评论(0) 推荐(0)
摘要:题目:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character'.'.You may assume that there will be... 阅读全文
posted @ 2015-04-17 23:15 YRB 阅读(678) 评论(0) 推荐(0)
摘要:题目: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled 阅读全文
posted @ 2015-04-17 23:11 YRB 阅读(682) 评论(0) 推荐(0)
摘要:题目: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted i 阅读全文
posted @ 2015-04-17 23:09 YRB 阅读(243) 评论(0) 推荐(0)
摘要:题目: Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in th 阅读全文
posted @ 2015-04-17 23:07 YRB 阅读(346) 评论(0) 推荐(0)
摘要:题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a targe 阅读全文
posted @ 2015-04-17 20:11 YRB 阅读(307) 评论(0) 推荐(0)
摘要:题目: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", th 阅读全文
posted @ 2015-04-17 16:08 YRB 阅读(459) 评论(0) 推荐(0)
摘要:题目: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not po 阅读全文
posted @ 2015-04-17 16:06 YRB 阅读(500) 评论(0) 推荐(0)
摘要:题目: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a c 阅读全文
posted @ 2015-04-17 15:53 YRB 阅读(441) 评论(0) 推荐(0)
摘要:题目: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 链接: http://leetcode.com/problems/d 阅读全文
posted @ 2015-04-17 15:51 YRB 阅读(1074) 评论(0) 推荐(0)
摘要:题目:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The... 阅读全文
posted @ 2015-04-17 15:30 YRB 阅读(638) 评论(0) 推荐(0)
摘要:题目: Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn' 阅读全文
posted @ 2015-04-17 15:29 YRB 阅读(311) 评论(0) 推荐(0)
摘要:题目: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra spac 阅读全文
posted @ 2015-04-17 15:00 YRB 阅读(226) 评论(0) 推荐(0)
摘要:题目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k th 阅读全文
posted @ 2015-04-17 14:27 YRB 阅读(476) 评论(0) 推荐(0)
摘要:题目: Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Yo 阅读全文
posted @ 2015-04-17 14:26 YRB 阅读(686) 评论(0) 推荐(0)
摘要:题目:Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.链接:http://leetcode.com/problems/merge-k-sorted-list... 阅读全文
posted @ 2015-04-17 14:08 YRB 阅读(700) 评论(0) 推荐(0)
摘要:题目: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set i 阅读全文
posted @ 2015-04-17 13:13 YRB 阅读(1097) 评论(0) 推荐(0)
摘要:题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 链接:  阅读全文
posted @ 2015-04-17 13:12 YRB 阅读(445) 评论(0) 推荐(0)
摘要:题目: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in 阅读全文
posted @ 2015-04-17 12:25 YRB 阅读(294) 评论(0) 推荐(0)
摘要:题目: Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this i 阅读全文
posted @ 2015-04-17 12:06 YRB 阅读(318) 评论(0) 推荐(0)
摘要:题目: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array 阅读全文
posted @ 2015-04-17 10:38 YRB 阅读(1359) 评论(0) 推荐(0)
摘要:题目: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the tel 阅读全文
posted @ 2015-04-17 00:17 YRB 阅读(2102) 评论(1) 推荐(0)
摘要:题目: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integ 阅读全文
posted @ 2015-04-16 17:23 YRB 阅读(437) 评论(0) 推荐(0)
摘要:题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum 阅读全文
posted @ 2015-04-16 11:20 YRB 阅读(520) 评论(0) 推荐(0)
摘要:题目: Write a function to find the longest common prefix string amongst an array of strings. 链接:http://leetcode.com/problems/longest-common-prefix/ 题解: 阅读全文
posted @ 2015-04-16 09:57 YRB 阅读(417) 评论(0) 推荐(0)
摘要:题目: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 链接: http://leetcode.com/problems/roman 阅读全文
posted @ 2015-04-16 09:36 YRB 阅读(318) 评论(0) 推荐(0)
摘要:题目: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 链接: http://leetcode.com/problems/integ 阅读全文
posted @ 2015-04-16 09:34 YRB 阅读(737) 评论(0) 推荐(0)
摘要:题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two e 阅读全文
posted @ 2015-04-16 00:14 YRB 阅读(327) 评论(0) 推荐(0)
摘要:题目: Implement regular expression matching with support for '.' and '*'. 链接:http://leetcode.com/problems/regular-expression-matching/ 题解: 这道题也卡了很久,一开始就 阅读全文
posted @ 2015-04-15 23:51 YRB 阅读(962) 评论(0) 推荐(0)
摘要:题目: Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Could negative integers be palindromes? (ie, -1 阅读全文
posted @ 2015-04-15 22:13 YRB 阅读(329) 评论(0) 推荐(0)
摘要:题目: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see be 阅读全文
posted @ 2015-04-15 22:02 YRB 阅读(368) 评论(0) 推荐(0)
摘要:题目: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers. Have you thought about this? He 阅读全文
posted @ 2015-04-15 21:54 YRB 阅读(1210) 评论(0) 推荐(0)
摘要:题目: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed f 阅读全文
posted @ 2015-04-15 21:51 YRB 阅读(425) 评论(0) 推荐(0)
摘要:题目:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest... 阅读全文
posted @ 2015-04-15 20:26 YRB 阅读(527) 评论(0) 推荐(0)
摘要:题目:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should ... 阅读全文
posted @ 2015-04-15 20:23 YRB 阅读(552) 评论(0) 推荐(0)
摘要:题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letter 阅读全文
posted @ 2015-04-15 19:01 YRB 阅读(377) 评论(0) 推荐(0)
摘要:题目: 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 sin 阅读全文
posted @ 2015-04-15 11:49 YRB 阅读(452) 评论(0) 推荐(0)
摘要:题目: 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 t 阅读全文
posted @ 2015-04-15 11:08 YRB 阅读(633) 评论(1) 推荐(0)
该文被密码保护。
posted @ 2015-04-15 10:43 YRB