03 2015 档案
摘要:A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message conta...
阅读全文
摘要: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....
阅读全文
摘要: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...
阅读全文
摘要:首先声明,都是转载的,理解知识为主要目的。http://www.cnblogs.com/zahxz/archive/2013/02/20/2918711.htmlC++内置的数组支持容器的机制,但是它不支持容器抽象的语义。要解决此问题我们自己实现这样的类。在标准C++中,用容器向量(vector)实...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:http://blog.chinaunix.net/uid-20698239-id-1891361.htmlhttp://blog.csdn.net/rstevens/article/details/1803801http://www.cnblogs.com/chengxuyuancc/p/3576...
阅读全文
摘要:http://blog.chinaunix.net/uid-20698239-id-1891361.htmlhttp://blog.csdn.net/rstevens/article/details/1803801http://www.cnblogs.com/chengxuyuancc/p/3576...
阅读全文
摘要: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...
阅读全文
摘要: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],...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:本文主要参考《unix环境高级编程》sigaction函数的功能是检查或修改与指定信号相关联的处理动作(可同时两种操作)。intsigaction(intsigno,conststructsigaction*restrict act,structsigaction*restrict oact);结构...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Implementint sqrt(int x).Compute and return the square root ofx.Hide TagsMathBinary Search思路:整体上用2分比逐个比较强。首先,给出一个错误的版本:错误之处在于红色部分,当mid较大时,mid*mid会超过IN...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Unique PathsTotal Accepted:36748Total Submissions:112531My SubmissionsQuestionSolutionA robot is located at the top-left corner of amxngrid (marked 'S...
阅读全文
摘要: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.Hide ...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Given a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially...
阅读全文
摘要: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].Hide TagsArray...
阅读全文
摘要: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...
阅读全文
摘要:Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ],...
阅读全文
摘要:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.思路:和 N-queens 一样,不过只统计个数而言,...
阅读全文
摘要:Then-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all distinc...
阅读全文
摘要:Implement pow(x,n).思路:可以连乘,但会超时,所以使用二分法:注意几点:1 不要写成pow(x, n/2)* pow(x, n/2) 还是会超时,因为还是会计算两遍,直接使用临时变量tmp= pow(x, n/2),然会return tmp*tmp2 注意int 有可能为负数3 注...
阅读全文
摘要:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.http://www.cnblogs.com/easonliu/p/364...
阅读全文
摘要:You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路一:b[i][j] = a[n-1...
阅读全文