会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Agentgamer
“It only takes 10 seconds to crush a man's ambitions. I need to take care that I protect mine.”
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
7
···
13
下一页
2017年6月11日
Excel Sheet Column Number
摘要: https://leetcode.com/problems/excel-sheet-column-number/#/description 另一个atoi
阅读全文
posted @ 2017-06-11 10:42 Agentgamer
阅读(129)
评论(0)
推荐(0)
2017年6月9日
Excel Sheet Column Title
摘要: https://leetcode.com/problems/excel-sheet-column-title/#/description 像傻屌一样想了半天。。。其实就是一个十进制转26 进制的问题。唯一的区别就是,这里没有0,所以如果有某一位遇到0 的话就要像上借一位。既对于26 进制来说是逢26
阅读全文
posted @ 2017-06-09 17:11 Agentgamer
阅读(101)
评论(0)
推荐(0)
2017年6月8日
Convert Sorted List to Binary Search Tree
摘要: https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/#/description 跟数组那题没有什么本质区别,唯一的障碍是,在数组里因为长度已知,所以求中位数很方便。但是链表里找中位数就麻烦一点了。 快慢指针再
阅读全文
posted @ 2017-06-08 16:07 Agentgamer
阅读(118)
评论(0)
推荐(0)
2017年6月7日
Convert Sorted Array to Binary Search Tree
摘要: https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/#/description 把升序数组转成一个height平衡二叉树。这个平衡两个字一开始吓到我了,后面发现用最直觉的方法转换的话,高度是保证平衡的,也就
阅读全文
posted @ 2017-06-07 10:58 Agentgamer
阅读(92)
评论(0)
推荐(0)
2017年6月5日
Linked List Cycle
摘要: https://leetcode.com/problems/linked-list-cycle/#/description 首先想到的思路就是,用hash 表来存下每个node 的指针,然后遍历链表,每个node 都去哈希表里查一下,如果之前遇到过就说明链表是有圈的。 另一个思路比较有启发性,就是看
阅读全文
posted @ 2017-06-05 18:30 Agentgamer
阅读(152)
评论(0)
推荐(0)
2017年6月2日
Single Number
摘要: https://leetcode.com/problems/single-number/#/description 找数组里的唯一单身狗,最简单的方法可以用O(n) 的空间做个哈希表计数。不用额外空间的话要运用异或的知识。1.相同的数异或为零,2.任何数异或0 为他自己。 所以只用把数组里所有数异或
阅读全文
posted @ 2017-06-02 11:09 Agentgamer
阅读(99)
评论(0)
推荐(0)
2017年6月1日
Sqrt(x)
摘要: https://leetcode.com/problems/sqrtx 这题实际上是要求实现牛顿法吧,但是暴力找也是可以accept 的,毕竟是以n^2 的速度逼近答案。
阅读全文
posted @ 2017-06-01 21:48 Agentgamer
阅读(107)
评论(0)
推荐(0)
Add Binary
摘要: https://leetcode.com/problems/add-binary/#/description 思路是把问题泛化成一个二进制carry 上浮的操作。比如从最低位开始,设置一个进位值,比如3,然后按照二进制的法则对这个carry 进行进位操作,既从低位到高位依次上浮,直到carry 为0
阅读全文
posted @ 2017-06-01 18:06 Agentgamer
阅读(101)
评论(0)
推荐(0)
2017年5月27日
Factorial Trailing Zeroes Add to List
摘要: https://leetcode.com/problems/factorial-trailing-zeroes/#/description 想到了要找2x5;也想到了只要找5,剩下的2 管够。也想到了除以25 这种情况。然后却写出了TLE 的方案。。。。 要写出logn 的方案只需想到一点就是,不停
阅读全文
posted @ 2017-05-27 00:28 Agentgamer
阅读(107)
评论(0)
推荐(0)
2017年5月26日
Integer to Roman
摘要: https://leetcode.com/problems/integer-to-roman 自己写了一堆啰嗦的规则来选‘最适合’ 的数,结果全是bug。不如直接把数字按位数拆开,然后一一映射来得简洁。
阅读全文
posted @ 2017-05-26 15:39 Agentgamer
阅读(98)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
7
···
13
下一页
公告