摘要: 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 西施豆腐渣 阅读(135) 评论(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 西施豆腐渣 阅读(187) 评论(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) 编辑