摘要:
Givennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.分析... 阅读全文
摘要:
Determine whether an integer is a palindrome. Do this without extra space.按照palindrome的定义,负数一定不是palindrome number。而且palindrome number肯定是沿着中轴(可能为一个数或者两... 阅读全文
摘要:
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... 阅读全文
摘要:
这道题可以用双指针的方法解,将两个指针p,q的距离保持在n-1,然后移动q到List的最后一个元素,那么此时p指向的便是the Nth node from the end。要删除这个node,要分两种情况,一种是该node为head,另一种该node是中间node。对于第一种情况,可以简单的采用以下... 阅读全文
摘要:
Question: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.要产生全部的combinations,我们需要一种有序的方式产生combination以达到既产生全部又没有重复的... 阅读全文
摘要:
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.分析:跟N-Queens一样,DFS+Backtrac... 阅读全文
摘要:
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... 阅读全文
摘要:
A declaration makes a name known to a programm. A definition creates the assocatied entity. A variable declaration specifies the variable type and nam... 阅读全文