上一页 1 2 3 4 5 6 ··· 16 下一页
摘要: class Solution {public: double pow(double x, int n) { double a=1; if(n==0)return 1; if(x==1)return 1; if(x==-1) { if(n&1)return -1; else return 1; } int absn=abs(n); a=power(x,absn); if(n>1); r... 阅读全文
posted @ 2013-09-03 14:26 代码改变未来 阅读(397) 评论(0) 推荐(0) 编辑
摘要: dfsclass Solution {public:string str[8]={"abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};vectors; vector letterCombinations(string digits) { s.clear(); dfs(digits,""); return s; } void dfs(string digits,stri 阅读全文
posted @ 2013-09-03 12:56 代码改变未来 阅读(1017) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: ListNode *reverseKGroup(ListNode *head, int k) { // Start typing your C/C++ solution below // DO NOT write int main() function int n=k; int len=0; ListNode *p=head; if (head == NULL || head->next == NULL||knext; } if (n > len) return head; ... 阅读全文
posted @ 2013-06-30 22:15 代码改变未来 阅读(1064) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: ListNode *mergeKLists(vector &lists) { int n=lists.size(); if(n==0)return NULL; ListNode *head=new ListNode(INT_MIN); ListNode *ret=head; int min; bool finish; while(1) { finish=true; min... 阅读全文
posted @ 2013-06-30 20:45 代码改变未来 阅读(935) 评论(0) 推荐(0) 编辑
摘要: Iclass Solution {public: int ladderLength(string start, string end, unordered_set &dict) { unordered_set added; queue q; int ret = 0; int lev1 = 1, lev2 = 0; q.push(start); added.insert(start); while(!q.empty()) { string s = q.fr... 阅读全文
posted @ 2013-06-28 16:05 代码改变未来 阅读(288) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: vector findSubstring(string S, vector &L) { vectorv; if(L.size()==0)return v; int length=L[0].size(); mapm; for(int i=0;im1; for(int i=0;i+L.size()*length::iterator it; int j,k; for(j=i,k=0;km[com... 阅读全文
posted @ 2013-06-26 21:52 代码改变未来 阅读(908) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: ListNode *removeNthFromEnd(ListNode *head, int n) { ListNode *a=head,*b=head; int i=0; ListNode *pre=head; while(inext; i++; } while(a!=NULL&&b!=NULL) { pre=b; a=a->next; b=b->ne... 阅读全文
posted @ 2013-06-24 16:21 代码改变未来 阅读(160) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: string convert(string s, int nRows) { string ret; int n=s.size(); vectorv(nRows); for(int i=0;i0&&iv(nRows); for(int i=0;i0;j--,i++) v[j]+=s[i]; } for(int i=0;i<nRows;i++) { for(int j=0;j<v[i... 阅读全文
posted @ 2013-06-24 15:28 代码改变未来 阅读(1504) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: bool isMatch(const char *s, const char *p) { // Start typing your C/C++ solution below // DO NOT write int main() function if (*p == '*'){//return true; while(*p == '*') ++p; if (*p == '\0') return true; while(*s != '\0... 阅读全文
posted @ 2013-06-24 14:11 代码改变未来 阅读(230) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: bool searchMatrix(vector<vector<int> > &matrix, int target) { int low=0,high=matrix.size()-1; if(high==-1)return 0; int level=0; //if(matrix[0][0]>target)return false; while(low<=high) { level=(low+high)/2; ... 阅读全文
posted @ 2013-06-17 14:20 代码改变未来 阅读(843) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 16 下一页