08 2014 档案

摘要:题目:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique... 阅读全文
posted @ 2014-08-08 00:26 爱做饭的小莹子 阅读(4862) 评论(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 @ 2014-08-07 10:29 爱做饭的小莹子 阅读(7926) 评论(0) 推荐(0) 编辑
摘要:题目:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.题解:其实我觉得这题。。为啥不给个更明确... 阅读全文
posted @ 2014-08-07 10:20 爱做饭的小莹子 阅读(8715) 评论(0) 推荐(0) 编辑
摘要:题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not pos... 阅读全文
posted @ 2014-08-07 09:09 爱做饭的小莹子 阅读(5398) 评论(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 seque... 阅读全文
posted @ 2014-08-07 08:33 爱做饭的小莹子 阅读(5827) 评论(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 @ 2014-08-07 05:25 爱做饭的小莹子 阅读(5186) 评论(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 ha... 阅读全文
posted @ 2014-08-07 04:51 爱做饭的小莹子 阅读(5083) 评论(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 represent... 阅读全文
posted @ 2014-08-07 03:44 爱做饭的小莹子 阅读(2937) 评论(0) 推荐(0) 编辑
摘要:题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message... 阅读全文
posted @ 2014-08-07 03:15 爱做饭的小莹子 阅读(6336) 评论(0) 推荐(0) 编辑
摘要:题目:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", r... 阅读全文
posted @ 2014-08-07 02:40 爱做饭的小莹子 阅读(2956) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed fro... 阅读全文
posted @ 2014-08-07 01:48 爱做饭的小莹子 阅读(5070) 评论(0) 推荐(1) 编辑
摘要:题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.题解:这道题就是给你一个2D平面,然后给你的数据结构是由横纵坐标表示的点,然后看哪条直线上的点... 阅读全文
posted @ 2014-08-07 00:35 爱做饭的小莹子 阅读(2955) 评论(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 fo... 阅读全文
posted @ 2014-08-06 03:37 爱做饭的小莹子 阅读(3499) 评论(0) 推荐(0) 编辑
摘要:题目:Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (includin... 阅读全文
posted @ 2014-08-06 03:25 爱做饭的小莹子 阅读(2769) 评论(0) 推荐(0) 编辑
摘要:题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding elem... 阅读全文
posted @ 2014-08-06 03:13 爱做饭的小莹子 阅读(5348) 评论(2) 推荐(1) 编辑
摘要:题目:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can b... 阅读全文
posted @ 2014-08-06 00:04 爱做饭的小莹子 阅读(3847) 评论(0) 推荐(0) 编辑
摘要:题目:Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter... 阅读全文
posted @ 2014-08-05 23:46 爱做饭的小莹子 阅读(5345) 评论(2) 推荐(0) 编辑
摘要:题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partition... 阅读全文
posted @ 2014-08-05 11:40 爱做饭的小莹子 阅读(5636) 评论(5) 推荐(2) 编辑
摘要:题目: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 @ 2014-08-05 03:16 爱做饭的小莹子 阅读(3593) 评论(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).F... 阅读全文
posted @ 2014-08-05 03:09 爱做饭的小莹子 阅读(2194) 评论(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 tree... 阅读全文
posted @ 2014-08-05 03:01 爱做饭的小莹子 阅读(3448) 评论(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 @ 2014-08-05 02:54 爱做饭的小莹子 阅读(3513) 评论(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 on... 阅读全文
posted @ 2014-08-04 11:22 爱做饭的小莹子 阅读(3271) 评论(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 @ 2014-08-04 11:15 爱做饭的小莹子 阅读(5667) 评论(0) 推荐(0) 编辑
摘要:题目:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function shou... 阅读全文
posted @ 2014-08-04 10:56 爱做饭的小莹子 阅读(1705) 评论(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 algorithm... 阅读全文
posted @ 2014-08-04 10:30 爱做饭的小莹子 阅读(2884) 评论(1) 推荐(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 @ 2014-08-04 09:35 爱做饭的小莹子 阅读(15635) 评论(1) 推荐(3) 编辑
摘要:题目: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 @ 2014-08-04 08:55 爱做饭的小莹子 阅读(2233) 评论(0) 推荐(0) 编辑
摘要:题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题解:二进制加法都是从最低位(从右加到左)。所以对两个字符串要从最后一位开始加,... 阅读全文
posted @ 2014-08-04 05:07 爱做饭的小莹子 阅读(4923) 评论(2) 推荐(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 @ 2014-08-04 03:52 爱做饭的小莹子 阅读(5385) 评论(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 @ 2014-08-04 03:22 爱做饭的小莹子 阅读(5736) 评论(0) 推荐(0) 编辑
摘要:题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes... 阅读全文
posted @ 2014-08-04 02:23 爱做饭的小莹子 阅读(3497) 评论(0) 推荐(0) 编辑
摘要:题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique lo... 阅读全文
posted @ 2014-08-04 02:08 爱做饭的小莹子 阅读(5499) 评论(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 @ 2014-08-03 09:18 爱做饭的小莹子 阅读(4981) 评论(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 c... 阅读全文
posted @ 2014-08-03 09:02 爱做饭的小莹子 阅读(2388) 评论(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 clarificatio... 阅读全文
posted @ 2014-08-03 08:50 爱做饭的小莹子 阅读(1537) 评论(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.click to show follow up.Follow up:Did you use extra s... 阅读全文
posted @ 2014-08-03 04:39 爱做饭的小莹子 阅读(3559) 评论(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 i... 阅读全文
posted @ 2014-08-03 04:32 爱做饭的小莹子 阅读(5545) 评论(2) 推荐(1) 编辑
摘要:题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to ... 阅读全文
posted @ 2014-08-03 02:59 爱做饭的小莹子 阅读(2651) 评论(0) 推荐(1) 编辑
摘要:题目: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... 阅读全文
posted @ 2014-08-03 02:45 爱做饭的小莹子 阅读(3891) 评论(0) 推荐(1) 编辑
摘要:题目: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... 阅读全文
posted @ 2014-08-03 02:34 爱做饭的小莹子 阅读(4303) 评论(1) 推荐(1) 编辑
摘要:题目: 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 foll... 阅读全文
posted @ 2014-08-03 02:17 爱做饭的小莹子 阅读(2392) 评论(0) 推荐(0) 编辑
摘要:题目:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[[ ... 阅读全文
posted @ 2014-08-03 02:07 爱做饭的小莹子 阅读(3369) 评论(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 @ 2014-08-02 23:49 爱做饭的小莹子 阅读(1870) 评论(0) 推荐(0) 编辑
摘要:题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next po... 阅读全文
posted @ 2014-08-02 23:36 爱做饭的小莹子 阅读(1952) 评论(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 spa... 阅读全文
posted @ 2014-08-02 10:39 爱做饭的小莹子 阅读(3551) 评论(0) 推荐(0) 编辑
摘要:题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at a... 阅读全文
posted @ 2014-08-02 10:28 爱做饭的小莹子 阅读(3720) 评论(0) 推荐(1) 编辑
摘要:题目: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 you... 阅读全文
posted @ 2014-08-02 10:14 爱做饭的小莹子 阅读(5763) 评论(2) 推荐(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 is... 阅读全文
posted @ 2014-08-02 10:03 爱做饭的小莹子 阅读(6154) 评论(0) 推荐(1) 编辑
摘要:题目: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?题解:这道题就是考察很... 阅读全文
posted @ 2014-08-02 09:09 爱做饭的小莹子 阅读(3174) 评论(0) 推荐(0) 编辑
摘要:题目:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. 题解:这道题跟interger to roman一样都得先熟悉罗马数字的规则。罗... 阅读全文
posted @ 2014-08-02 09:01 爱做饭的小莹子 阅读(2621) 评论(0) 推荐(0) 编辑
摘要:题目:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.题解:这道题。。还有哪个roman to integer。。第一件事 就是先把r... 阅读全文
posted @ 2014-08-02 08:43 爱做饭的小莹子 阅读(5013) 评论(0) 推荐(0) 编辑
摘要:题目:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here... 阅读全文
posted @ 2014-08-02 08:12 爱做饭的小莹子 阅读(3218) 评论(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 @ 2014-08-02 07:51 爱做饭的小莹子 阅读(2300) 评论(3) 推荐(0) 编辑
摘要:题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return [... 阅读全文
posted @ 2014-08-02 07:47 爱做饭的小莹子 阅读(4138) 评论(0) 推荐(1) 编辑
摘要:题目: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 @ 2014-08-02 00:24 爱做饭的小莹子 阅读(2872) 评论(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 @ 2014-08-01 10:11 爱做饭的小莹子 阅读(5417) 评论(0) 推荐(1) 编辑
摘要:题目: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 ... 阅读全文
posted @ 2014-08-01 09:55 爱做饭的小莹子 阅读(4145) 评论(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 @ 2014-08-01 09:43 爱做饭的小莹子 阅读(4721) 评论(0) 推荐(2) 编辑
摘要:题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For exam... 阅读全文
posted @ 2014-08-01 09:28 爱做饭的小莹子 阅读(3375) 评论(1) 推荐(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 @ 2014-08-01 09:09 爱做饭的小莹子 阅读(3662) 评论(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 w... 阅读全文
posted @ 2014-08-01 06:08 爱做饭的小莹子 阅读(1970) 评论(2) 推荐(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.题解:这道题跟pre... 阅读全文
posted @ 2014-08-01 05:59 爱做饭的小莹子 阅读(1659) 评论(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.题解: 1 ... 阅读全文
posted @ 2014-08-01 05:44 爱做饭的小莹子 阅读(5269) 评论(0) 推荐(0) 编辑
摘要:题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题解:之前做过一道是从sorted array转换到BinarySearc... 阅读全文
posted @ 2014-08-01 04:25 爱做饭的小莹子 阅读(2991) 评论(1) 推荐(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 @ 2014-08-01 03:47 爱做饭的小莹子 阅读(5572) 评论(0) 推荐(0) 编辑
摘要:下面应用转自Wikipedia(http://zh.wikipedia.org/wiki/%E5%8D%A1%E5%A1%94%E5%85%B0%E6%95%B0):组合数学中有非常多的组合结构可以用卡塔兰数来计数。在Richard P. Stanley的Enumerative Combinato... 阅读全文
posted @ 2014-08-01 03:03 爱做饭的小莹子 阅读(914) 评论(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 B... 阅读全文
posted @ 2014-08-01 02:58 爱做饭的小莹子 阅读(5135) 评论(4) 推荐(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 "ad... 阅读全文
posted @ 2014-08-01 02:06 爱做饭的小莹子 阅读(5070) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示