摘要: Code:class Solution {public: bool hasCycle(ListNode *head) { ListNode *p=head; ListNode *cur=head; while(p){ if(p->next) p=p->next->next; else return false; cur=cur->next; if(p==cur) retu... 阅读全文
posted @ 2013-10-30 07:46 WinsCoder 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Code:class Solution {public: vector > fourSum(vector &num, int target) { vector buf; vector> res; if(num.size()p+2;q--) { i=p+1; j=q-1; while(ip+2&&num[q]==num[q-1]) q--; } while(... 阅读全文
posted @ 2013-10-30 07:44 WinsCoder 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Code:class Solution {public: vector> threeSum(vector &num) { vector buf; vector> res; if(num.empty()) return res; sort(num.begin(),num.end()); int n=num.size(); int i,j,k; for(i=0;i<n-2;i++) { j=i+1; k=n-1; w... 阅读全文
posted @ 2013-10-30 07:42 WinsCoder 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Code:class Solution {public: string intToRoman(int num) { string roman; int nums[13] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; char symbols[13] = {'M', 'C', 'D', 'C', 'C', 'X', 'L', 'X', 'X', 'I', 'V& 阅读全文
posted @ 2013-10-30 07:41 WinsCoder 阅读(127) 评论(0) 推荐(0) 编辑