上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 30 下一页
摘要: uint32_t reverseBits(uint32_t n) { auto strBits = bitset(n).to_string(); return static_cast(bitset(string(strBits.crbegin(), strBits.crend())).t... 阅读全文
posted @ 2015-08-07 16:30 wu_overflow 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(125) 评论(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 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 链表和树都自带递归特性,我很喜欢。这一题很简单,有意思的是我是先把内部的 lambda 表达式写出来之后才发现可以直接用这个函数本身做递归。ListNode* removeElements(ListNode* head, int val) { if (head == nullptr){ ... 阅读全文
posted @ 2015-08-06 13:53 wu_overflow 阅读(125) 评论(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 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 我自己的方法是用的递归,毕竟也是接触了一点点点点点点 scheme 的骚年是吧,代码如下:ListNode* reverseList(ListNode* head) { if (head == nullptr){ return nullptr; } ListN... 阅读全文
posted @ 2015-08-04 17:15 wu_overflow 阅读(158) 评论(0) 推荐(0) 编辑
摘要: bool containsDuplicate(vector& nums) { return !(nums.size() == unordered_set(nums.cbegin(), nums.cend()).size());} 阅读全文
posted @ 2015-08-04 08:15 wu_overflow 阅读(277) 评论(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 阅读(138) 评论(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 阅读(182) 评论(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 阅读(200) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 30 下一页