Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?...
分类:
其他好文 时间:
2014-08-02 12:53:53
阅读次数:
289
题目: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....
分类:
编程语言 时间:
2014-08-02 12:19:13
阅读次数:
241
题目: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 ....
分类:
编程语言 时间:
2014-08-02 01:48:12
阅读次数:
246
问题描述:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->...
分类:
其他好文 时间:
2014-08-02 01:33:12
阅读次数:
249
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 contain duplicate subsets.
For exa...
分类:
其他好文 时间:
2014-08-01 23:18:42
阅读次数:
246
问题:罗马数字变为整数class Solution {public: int romanToInt(string s) { char c[10][10][10]={{"0","I","II","III","IV","V","VI","VII","VIII","IX"},{"0"...
分类:
其他好文 时间:
2014-08-01 23:01:02
阅读次数:
209
描述:注意需要先self.connect(right)再self.connect(left),否则会有case通不过,原因是左边递归执行时依赖与右边的next已经建立,而先执行connect(left)的话右边还没有完成关系的建立。代码: 1 class Solution: 2 # @par...
分类:
其他好文 时间:
2014-08-01 19:15:42
阅读次数:
223
这道题实质是用螺旋线的形式遍历二维数组,而且这种遍历方式有很强的规律性,从最外层开始一直到最里层,而且每层都按顺时针的方向遍历。根据这种规律性,我们可以用两层循环,在遍历的同时对二维数组对应元素重新赋值,第一层循环是层数遍历,第二层循环是每一层元素遍历(值得注意的一点是顺时针遍历)。class So...
分类:
其他好文 时间:
2014-08-01 18:54:02
阅读次数:
217
class Solution {public: int totalNQueens(int n) { //initialize chessboard vector> boardconf; vector orig_row; orig_row....
分类:
编程语言 时间:
2014-08-01 15:46:51
阅读次数:
251
Greedy, Greedy, Greedy.. It is all about maximum interval update.One trick is, we start looping over each element from the one nearest to end to farth...
分类:
其他好文 时间:
2014-08-01 13:32:21
阅读次数:
283