12 2014 档案

摘要:Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callin... 阅读全文
posted @ 2014-12-31 16:32 陆草纯 阅读(5162) 评论(1) 推荐(1) 编辑
摘要:Missing RangesGiven a sorted integer array where the range of elements are [lower, upper] inclusive, return its missing ranges.For example, given [0, ... 阅读全文
posted @ 2014-12-31 15:51 陆草纯 阅读(1687) 评论(2) 推荐(0) 编辑
摘要:Exercise:Vectorization习题的链接:Exercise:Vectorization注意点:MNIST图片的像素点已经经过归一化。如果再使用Exercise:Sparse Autoencoder中的sampleIMAGES.m进行归一化,将使得训练得到的可视化权值如下图:更改trai... 阅读全文
posted @ 2014-12-31 13:43 陆草纯 阅读(685) 评论(0) 推荐(0) 编辑
摘要:Exercise:Sparse Autoencoder习题的链接:Exercise:Sparse Autoencoder注意点:1、训练样本像素值需要归一化。因为输出层的激活函数是logistic函数,值域(0,1),如果训练样本每个像素点没有进行归一化,那将无法进行自编码。2、训练阶段,向量化实现... 阅读全文
posted @ 2014-12-30 16:21 陆草纯 阅读(1267) 评论(2) 推荐(0) 编辑
摘要:(一)Autoencoders and Sparsity章节公式错误:s2 应为 s3。意为从第2层(隐藏层)i节点到输出层j节点的误差加权和。(二)Support functions for loading MNIST in Matlab文件名错误% Change the filenames if... 阅读全文
posted @ 2014-12-30 15:02 陆草纯 阅读(340) 评论(0) 推荐(0) 编辑
摘要:Factorial Trailing ZeroesGiven an integern, return the number of trailing zeroes inn!.Note:Your solution should be in logarithmic time complexity.Cred... 阅读全文
posted @ 2014-12-30 12:47 陆草纯 阅读(9082) 评论(3) 推荐(3) 编辑
摘要:Binary Tree Upside DownGiven a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent nod... 阅读全文
posted @ 2014-12-29 12:11 陆草纯 阅读(1751) 评论(2) 推荐(0) 编辑
摘要:Excel Sheet Column NumberRelated to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column ... 阅读全文
posted @ 2014-12-29 10:40 陆草纯 阅读(3912) 评论(0) 推荐(0) 编辑
摘要:Longest Substring with At Most Two Distinct CharactersGiven a string, find the length of the longest substring T that contains at most 2 distinct char... 阅读全文
posted @ 2014-12-28 16:00 陆草纯 阅读(1731) 评论(0) 推荐(0) 编辑
摘要:1、相同点:回溯法在实现上也是遵循深度优先的,即一步一步往前探索,而不像广度优先那样,由近及远一片一片地扫。2、不同点(1)访问序深度优先遍历: 目的是“遍历”,本质是无序的。也就是说访问次序不重要,重要的是都被访问过了。可以参见题Surrounded Regions,深度优先只需要把从边界起始的... 阅读全文
posted @ 2014-12-27 11:08 陆草纯 阅读(13754) 评论(1) 推荐(2) 编辑
摘要:1、使用结构体grid作为map的keystruct grid{ int x; int y;};(1)需要自定义比较函数operator &,const std::deque &)”: 未能从“const grid”为“const std::deque &”推导 模板 参数(2)需要定义... 阅读全文
posted @ 2014-12-26 20:59 陆草纯 阅读(3513) 评论(0) 推荐(1) 编辑
摘要:Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run... 阅读全文
posted @ 2014-12-23 17:14 陆草纯 阅读(5471) 评论(0) 推荐(1) 编辑
摘要:Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ... 阅读全文
posted @ 2014-12-23 13:40 陆草纯 阅读(220) 评论(0) 推荐(0) 编辑
摘要:Add Two NumbersYou are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes co... 阅读全文
posted @ 2014-12-23 11:44 陆草纯 阅读(221) 评论(0) 推荐(0) 编辑
摘要:Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there... 阅读全文
posted @ 2014-12-22 23:33 陆草纯 阅读(247) 评论(0) 推荐(0) 编辑
摘要:ZigZag ConversionThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern i... 阅读全文
posted @ 2014-12-22 23:14 陆草纯 阅读(1014) 评论(0) 推荐(0) 编辑
摘要:String to Integer (atoi)Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, plea... 阅读全文
posted @ 2014-12-22 11:30 陆草纯 阅读(281) 评论(0) 推荐(0) 编辑
摘要:Majority ElementGiven an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may ass... 阅读全文
posted @ 2014-12-22 10:38 陆草纯 阅读(9673) 评论(6) 推荐(1) 编辑
摘要:Palindrome NumberDetermine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers b... 阅读全文
posted @ 2014-12-21 21:21 陆草纯 阅读(266) 评论(0) 推荐(0) 编辑
摘要:Regular Expression MatchingImplement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more o... 阅读全文
posted @ 2014-12-21 15:22 陆草纯 阅读(6139) 评论(0) 推荐(2) 编辑
摘要:Container With Most WaterGivennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such t... 阅读全文
posted @ 2014-12-21 14:59 陆草纯 阅读(212) 评论(0) 推荐(0) 编辑
摘要:Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.逐区间做处理。解法一:非递归class Solution... 阅读全文
posted @ 2014-12-21 13:21 陆草纯 阅读(293) 评论(0) 推荐(0) 编辑
摘要:Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.解法一:非递归从左到右遍历每个字符,并记录上个字符来处理... 阅读全文
posted @ 2014-12-21 12:57 陆草纯 阅读(320) 评论(0) 推荐(0) 编辑
摘要:3Sum ClosestGiven an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three int... 阅读全文
posted @ 2014-12-21 12:16 陆草纯 阅读(197) 评论(0) 推荐(0) 编辑
摘要:4SumGiven an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum... 阅读全文
posted @ 2014-12-21 11:11 陆草纯 阅读(514) 评论(0) 推荐(0) 编辑
摘要:Excel Sheet Column TitleGiven a non-zero positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A ... 阅读全文
posted @ 2014-12-20 21:06 陆草纯 阅读(8480) 评论(6) 推荐(0) 编辑
摘要:Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit ... 阅读全文
posted @ 2014-12-20 14:08 陆草纯 阅读(3958) 评论(0) 推荐(0) 编辑
摘要:Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must clos... 阅读全文
posted @ 2014-12-20 11:44 陆草纯 阅读(196) 评论(0) 推荐(0) 编辑
摘要:Generate ParenthesesGivennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a sol... 阅读全文
posted @ 2014-12-20 11:01 陆草纯 阅读(269) 评论(0) 推荐(0) 编辑
摘要:Merge k Sorted ListsMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.多路归并。1、用make_heap函数维护一个大小为k的最小堆。注:... 阅读全文
posted @ 2014-12-20 10:21 陆草纯 阅读(377) 评论(0) 推荐(0) 编辑
摘要:Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2-... 阅读全文
posted @ 2014-12-19 16:10 陆草纯 阅读(303) 评论(0) 推荐(0) 编辑
摘要:Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a... 阅读全文
posted @ 2014-12-19 16:02 陆草纯 阅读(427) 评论(0) 推荐(0) 编辑
摘要:Divide Two IntegersDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.不能用乘法,我们可以移位啊,移p位就相当于... 阅读全文
posted @ 2014-12-19 15:37 陆草纯 阅读(3839) 评论(0) 推荐(1) 编辑
摘要:Substring with Concatenation of All WordsYou are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices o... 阅读全文
posted @ 2014-12-18 21:37 陆草纯 阅读(229) 评论(0) 推荐(0) 编辑
摘要:Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen... 阅读全文
posted @ 2014-12-18 12:58 陆草纯 阅读(321) 评论(0) 推荐(0) 编辑
摘要:Longest Valid ParenthesesGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substr... 阅读全文
posted @ 2014-12-18 10:39 陆草纯 阅读(323) 评论(0) 推荐(0) 编辑
摘要:1、局部静态变量(1)生存期:存储在静态数据区,本模块运行结束不会销毁,程序结束时才销毁。(2)初始化:当且仅当本模块初次运行时初始化。2、外部静态变量/静态函数限制全局变量的作用域为本文件。3、静态数据成员/成员函数表示该成员/成员函数属于此类,不依附与具体对象。常用于生成对象的计数器。 阅读全文
posted @ 2014-12-18 10:20 陆草纯 阅读(182) 评论(0) 推荐(0) 编辑
摘要:形式:在成员函数后面加上const限定词,表示不会修改对象内容。例如Circle类:class Circle{ double r;public: Circle(double newr) { r = newr; } double get_r() const ... 阅读全文
posted @ 2014-12-18 09:51 陆草纯 阅读(246) 评论(0) 推荐(0) 编辑
摘要:Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ... 阅读全文
posted @ 2014-12-17 23:01 陆草纯 阅读(256) 评论(0) 推荐(0) 编辑
摘要:Valid SudokuDetermine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are ... 阅读全文
posted @ 2014-12-17 22:45 陆草纯 阅读(6178) 评论(2) 推荐(1) 编辑
摘要:Fraction to Recurring DecimalGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the ... 阅读全文
posted @ 2014-12-17 22:25 陆草纯 阅读(4455) 评论(0) 推荐(0) 编辑
摘要:Count and SayThe count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is r... 阅读全文
posted @ 2014-12-16 17:17 陆草纯 阅读(243) 评论(0) 推荐(0) 编辑
摘要:Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sum... 阅读全文
posted @ 2014-12-16 15:11 陆草纯 阅读(2995) 评论(0) 推荐(0) 编辑
摘要:First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given[1,2,0]return3,and[3,4,-1,1]return2.Yo... 阅读全文
posted @ 2014-12-15 14:39 陆草纯 阅读(377) 评论(0) 推荐(0) 编辑
摘要:Trapping Rain WaterGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to tr... 阅读全文
posted @ 2014-12-15 14:17 陆草纯 阅读(274) 评论(0) 推荐(0) 编辑
摘要:Maximum GapGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/spac... 阅读全文
posted @ 2014-12-14 10:39 陆草纯 阅读(8026) 评论(0) 推荐(0) 编辑
摘要:Multiply StringsGiven two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large ... 阅读全文
posted @ 2014-12-13 22:51 陆草纯 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Wildcard MatchingImplement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters... 阅读全文
posted @ 2014-12-13 19:56 陆草纯 阅读(1080) 评论(0) 推荐(0) 编辑
摘要:区分const出现在*前还是*后前:例如const int *p,这种表示情况下,p本身可以改变,即p可以指向不同的地址,但是p指向的内容不可改变。就像你喜欢看书,图书馆规定你可以任意借阅及更换书本,但是你不能涂改书中的内容。后:例如int* const p,这种表示情况下,p指向地址不能改变,但是... 阅读全文
posted @ 2014-12-13 19:41 陆草纯 阅读(186) 评论(0) 推荐(0) 编辑
摘要:Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the follow... 阅读全文
posted @ 2014-12-13 18:23 陆草纯 阅读(2038) 评论(1) 推荐(0) 编辑
摘要:PermutationsGiven 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]... 阅读全文
posted @ 2014-12-13 14:49 陆草纯 阅读(1833) 评论(1) 推荐(0) 编辑
摘要:AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.首先解释一下什么是anagrams:在不考虑顺序的情况下,... 阅读全文
posted @ 2014-12-13 14:20 陆草纯 阅读(417) 评论(0) 推荐(0) 编辑
摘要:Pow(x, n)Implement pow(x,n).按照定义做的O(n)肯定是TLE的。利用这个信息:x2n = (xn)2有个注意点,当n为负是,直接取反是不可行的。由于int的表示范围是[2-31, 231-1],当n为INT_MIN时,取反会溢出。因此需要对n==INT_MIN单独考虑。另... 阅读全文
posted @ 2014-12-13 12:40 陆草纯 阅读(503) 评论(0) 推荐(0) 编辑
摘要:N-Queens IIFollow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.简单的回溯法。cur[i] ==... 阅读全文
posted @ 2014-12-12 10:46 陆草纯 阅读(294) 评论(0) 推荐(0) 编辑
摘要:Merge IntervalsGiven 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]... 阅读全文
posted @ 2014-12-11 23:19 陆草纯 阅读(1163) 评论(0) 推荐(0) 编辑
摘要:Insert IntervalGiven a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals... 阅读全文
posted @ 2014-12-11 20:40 陆草纯 阅读(1822) 评论(0) 推荐(1) 编辑
摘要:Length of Last WordGiven a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.I... 阅读全文
posted @ 2014-12-11 16:42 陆草纯 阅读(171) 评论(0) 推荐(0) 编辑
摘要:Spiral Matrix IIGiven an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the... 阅读全文
posted @ 2014-12-11 13:37 陆草纯 阅读(141) 评论(0) 推荐(0) 编辑
摘要:Spiral MatrixGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[... 阅读全文
posted @ 2014-12-11 13:07 陆草纯 阅读(1416) 评论(0) 推荐(0) 编辑
摘要:给定正整数n,求1,2,3,...,n的全排列解法一:递归,结果并不为字母序排列。void Helper(vector v, int low, int high){ if(low == high) { for(int i = 0; i v(n,0); for(int... 阅读全文
posted @ 2014-12-10 20:43 陆草纯 阅读(344) 评论(0) 推荐(0) 编辑
摘要:Permutation SequenceThe set[1,2,3,…,n]contains a total ofn! unique permutations.By listing and labeling all of the permutations in order,We get the fo... 阅读全文
posted @ 2014-12-10 20:02 陆草纯 阅读(1536) 评论(0) 推荐(0) 编辑
摘要:Rotate ListGiven 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-... 阅读全文
posted @ 2014-12-10 14:44 陆草纯 阅读(1098) 评论(0) 推荐(0) 编辑
摘要:Unique Paths IIFollow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle an... 阅读全文
posted @ 2014-12-10 13:36 陆草纯 阅读(427) 评论(0) 推荐(0) 编辑
摘要:Unique PathsA 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 a... 阅读全文
posted @ 2014-12-10 13:17 陆草纯 阅读(3069) 评论(0) 推荐(1) 编辑
摘要:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fir... 阅读全文
posted @ 2014-12-10 12:54 陆草纯 阅读(151) 评论(0) 推荐(0) 编辑
摘要:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".先进行对齐操作,然后从右往左逐位相加,注意进位即可。class Solut... 阅读全文
posted @ 2014-12-10 11:29 陆草纯 阅读(2313) 评论(0) 推荐(0) 编辑
摘要:Valid NumberValidate 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 ... 阅读全文
posted @ 2014-12-10 10:59 陆草纯 阅读(202) 评论(0) 推荐(0) 编辑
摘要:Plus OneGiven a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant dig... 阅读全文
posted @ 2014-12-09 23:31 陆草纯 阅读(2135) 评论(0) 推荐(0) 编辑
摘要:Text JustificationGiven an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) just... 阅读全文
posted @ 2014-12-09 21:24 陆草纯 阅读(405) 评论(0) 推荐(0) 编辑
摘要:Sqrt(x)Implementint sqrt(int x).Compute and return the square root ofx.解法一:牛顿迭代法求n的平方根,即求f(x)=x2-n的零点设初始值为x0,注,不要设为0,以免出现除数为0,见后。则过(x0,f(x0))点的切线为g(x)... 阅读全文
posted @ 2014-12-09 18:53 陆草纯 阅读(246) 评论(0) 推荐(0) 编辑
摘要:Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You... 阅读全文
posted @ 2014-12-09 15:51 陆草纯 阅读(206) 评论(0) 推荐(0) 编辑
摘要:Set Matrix ZeroesGiven 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 us... 阅读全文
posted @ 2014-12-09 14:11 陆草纯 阅读(247) 评论(0) 推荐(0) 编辑
摘要:Minimum Window SubstringGiven 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).Fo... 阅读全文
posted @ 2014-12-09 13:24 陆草纯 阅读(4955) 评论(1) 推荐(0) 编辑
摘要:1、计数排序如果给定上下界,并且区间不大的话,最适用。比如对于英文字母数组进行排序。时间复杂度O(n),空间复杂度O(n)void countSort(int A[], int n, int low, int high){ int size = high-low+1; vector co... 阅读全文
posted @ 2014-12-08 19:16 陆草纯 阅读(255) 评论(0) 推荐(0) 编辑
摘要:CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3... 阅读全文
posted @ 2014-12-07 00:01 陆草纯 阅读(395) 评论(0) 推荐(0) 编辑
摘要:Search in Rotated Sorted Array IIFollow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity... 阅读全文
posted @ 2014-12-06 19:10 陆草纯 阅读(401) 评论(0) 推荐(0) 编辑
摘要:Search in Rotated Sorted ArraySuppose 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).... 阅读全文
posted @ 2014-12-06 18:38 陆草纯 阅读(2077) 评论(0) 推荐(0) 编辑
摘要:Remove Duplicates from Sorted ListGiven a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, r... 阅读全文
posted @ 2014-12-06 16:39 陆草纯 阅读(142) 评论(0) 推荐(0) 编辑
摘要:Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or... 阅读全文
posted @ 2014-12-06 16:26 陆草纯 阅读(217) 评论(0) 推荐(0) 编辑
摘要:Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.如果用DP来做,判断(begin... 阅读全文
posted @ 2014-12-06 15:56 陆草纯 阅读(521) 评论(0) 推荐(0) 编辑
摘要:Largest Rectangle in HistogramGivennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of l... 阅读全文
posted @ 2014-12-06 15:24 陆草纯 阅读(8416) 评论(1) 推荐(0) 编辑
摘要:Scramble StringGiven a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible... 阅读全文
posted @ 2014-12-06 11:11 陆草纯 阅读(1792) 评论(1) 推荐(0) 编辑
摘要:Find Peak ElementA 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 ... 阅读全文
posted @ 2014-12-05 23:16 陆草纯 阅读(4722) 评论(0) 推荐(0) 编辑
摘要:Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the tot... 阅读全文
posted @ 2014-12-05 15:41 陆草纯 阅读(736) 评论(0) 推荐(0) 编辑
摘要:SubsetsGiven 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... 阅读全文
posted @ 2014-12-05 11:22 陆草纯 阅读(262) 评论(0) 推荐(0) 编辑
摘要:Subsets IIGiven a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descend... 阅读全文
posted @ 2014-12-04 18:47 陆草纯 阅读(2181) 评论(0) 推荐(0) 编辑
摘要:Reverse Linked List IIReverse 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,return... 阅读全文
posted @ 2014-12-04 16:59 陆草纯 阅读(1400) 评论(0) 推荐(0) 编辑
摘要:Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ... 阅读全文
posted @ 2014-12-02 21:09 陆草纯 阅读(238) 评论(0) 推荐(0) 编辑
摘要:Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your pr... 阅读全文
posted @ 2014-12-02 20:02 陆草纯 阅读(2726) 评论(0) 推荐(0) 编辑
摘要:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a to... 阅读全文
posted @ 2014-12-02 18:31 陆草纯 阅读(288) 评论(0) 推荐(0) 编辑
摘要:Interleaving StringGivens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", r... 阅读全文
posted @ 2014-12-02 16:32 陆草纯 阅读(4851) 评论(0) 推荐(0) 编辑
摘要:Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre... 阅读全文
posted @ 2014-12-02 14:44 陆草纯 阅读(246) 评论(0) 推荐(0) 编辑
摘要:Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol... 阅读全文
posted @ 2014-12-02 13:00 陆草纯 阅读(831) 评论(0) 推荐(0) 编辑
摘要:Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally ide... 阅读全文
posted @ 2014-12-01 22:57 陆草纯 阅读(4662) 评论(0) 推荐(1) 编辑
摘要:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric... 阅读全文
posted @ 2014-12-01 13:25 陆草纯 阅读(258) 评论(0) 推荐(0) 编辑

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