上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 30 下一页
摘要: void rotate(vector& nums, int k) { if (nums.empty() || k == 0 || nums.size() == 1){ return; } k %= nums.size(); vector newNums(... 阅读全文
posted @ 2015-08-07 15:40 wu_overflow 阅读(132) 评论(0) 推荐(0)
摘要: bool isHappy(int n) { // If not happy, it will finally recycle in the checkList. array checkList{4,16,37,58,89,145,42,20}; auto caculate ... 阅读全文
posted @ 2015-08-06 15:24 wu_overflow 阅读(285) 评论(0) 推荐(0)
摘要: 链表和树都自带递归特性,我很喜欢。这一题很简单,有意思的是我是先把内部的 lambda 表达式写出来之后才发现可以直接用这个函数本身做递归。ListNode* removeElements(ListNode* head, int val) { if (head == nullptr){ ... 阅读全文
posted @ 2015-08-06 13:53 wu_overflow 阅读(136) 评论(0) 推荐(0)
摘要: bool containsNearbyDuplicate(vector& nums, int k) { unordered_map> numIndexListDic; for (size_t i = 0; i {i}; } else{ a... 阅读全文
posted @ 2015-08-05 12:35 wu_overflow 阅读(160) 评论(0) 推荐(0)
摘要: 我自己的方法是用的递归,毕竟也是接触了一点点点点点点 scheme 的骚年是吧,代码如下:ListNode* reverseList(ListNode* head) { if (head == nullptr){ return nullptr; } ListN... 阅读全文
posted @ 2015-08-04 17:15 wu_overflow 阅读(169) 评论(0) 推荐(0)
摘要: bool containsDuplicate(vector& nums) { return !(nums.size() == unordered_set(nums.cbegin(), nums.cend()).size());} 阅读全文
posted @ 2015-08-04 08:15 wu_overflow 阅读(291) 评论(0) 推荐(0)
摘要: class Stack {private: queue que;public: // Push element x onto stack. void push(int x) { que.push(x); } // Removes the eleme... 阅读全文
posted @ 2015-08-04 07:47 wu_overflow 阅读(146) 评论(0) 推荐(0)
摘要: class Queue {private: stack in; stack out; void reverseStackToOut() { auto size = in.size(); for (size_t i = 0; i < size... 阅读全文
posted @ 2015-08-03 22:28 wu_overflow 阅读(189) 评论(0) 推荐(0)
摘要: def summary_ranges(nums) summary = []; if nums.size == 0 return summary end if nums.size == 1 return summary #{nums[i - 1]}"... 阅读全文
posted @ 2015-08-03 22:10 wu_overflow 阅读(205) 评论(0) 推荐(0)
摘要: 思路很简单,出口是空节点,先翻转子节点,再返回。TreeNode* invertTree(TreeNode* root) { if (root == nullptr){ return root; } invertTree(root->left); ... 阅读全文
posted @ 2015-08-03 20:26 wu_overflow 阅读(231) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 30 下一页