上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页
摘要: Valid ParenthesesJan 30 '12Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct order,"()"and"()[]{}"are all valid but"(]" 阅读全文
posted @ 2013-01-25 05:00 西施豆腐渣 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"public class Solution { private ArrayList<String> rel 阅读全文
posted @ 2013-01-24 18:35 西施豆腐渣 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 第一个数字是在数组里,第二个是个32bit uintuncompleted, not mine code.void add(vector<int> & a, uint b) { int remainder = 0; int i; for(i = a.size() - 1; i > -1 && b > 0; --i) { a[i] += remainder + b % 10; b = b / 10; if(a[i] >= 1... 阅读全文
posted @ 2013-01-24 18:30 西施豆腐渣 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Apr 2 '12Validate 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 statement to be ambiguous. You should gather all requirements up front befor 阅读全文
posted @ 2013-01-24 18:22 西施豆腐渣 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Feb 15 '12Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algorithm should use only constant space. You maynotmodify the values in the list, only nodes itself can be changed./*** De 阅读全文
posted @ 2013-01-23 16:03 西施豆腐渣 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Jun 25 '12Given 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 solution set must not contain duplicate subsets.For example,IfS=[1,2,2], a solution is:[ [2], [1], [1,2,2], [2,2], [1,2], []... 阅读全文
posted @ 2013-01-23 15:13 西施豆腐渣 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 4.findoutpythagoreantripletsinanintegerarray.#include <iostream> #include <vector> #include <set> #include <cmath> using namespace std; vector<vector<int> > findP( vector<int> & x ) { set<int> pool; vector<vector<int> > rel; if(x.size() 阅读全文
posted @ 2013-01-23 07:44 西施豆腐渣 阅读(186) 评论(0) 推荐(0) 编辑
摘要: integersofsymmetricdigitscoplexity: O(n)#include <iostream> #include <vector> using namespace std; bool isSymetric( int x ) { char buff[32]; int i=0; while( x != 0){ buff[i++] = x%10; x/=10; } int j=0; i-=1; while( j<i) { if(buff[j++] != buff[i--] ) return false; } return true; } ... 阅读全文
posted @ 2013-01-23 06:28 西施豆腐渣 阅读(108) 评论(0) 推荐(0) 编辑
摘要: 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 example,IfS=[1,2,3], a solution is:[ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ]class Solution {publ... 阅读全文
posted @ 2013-01-22 18:52 西施豆腐渣 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are 阅读全文
posted @ 2013-01-19 19:33 西施豆腐渣 阅读(132) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 14 下一页