会员
周边
新闻
博问
闪存
赞助商
YouClaw
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
wu_overflow
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
6
7
8
9
10
11
12
13
14
···
30
下一页
2015年8月7日
翻转数组
摘要: 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)
2015年8月6日
判断是否是快乐数
摘要: 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)
2015年8月5日
判断是否存在相距 k 以内的相同值
摘要: 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)
2015年8月4日
逆置单链表
摘要: 我自己的方法是用的递归,毕竟也是接触了一点点点点点点 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)
2015年8月3日
用栈实现队列
摘要: 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
下一页
公告