会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
fish1996
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
3
4
5
6
···
13
下一页
2019年8月16日
[贪心] leetcode 927 Three Equal Parts
摘要: problem: https://leetcode.com/problems/three-equal-parts/ 首先,检测有多少个1,记作x,看是不是3的倍数。不是则说明不存在对应划分。 之后,检测末尾的0,作为每个二进制数末尾的0个数,记作y。 最后,检测是否存在3个连续、不相交的,总共包含
阅读全文
posted @ 2019-08-16 21:47 fish1996
阅读(215)
评论(0)
推荐(0)
2019年8月12日
[宽度优先搜索] leetcode 743 Network Delay Time
摘要: problem:https://leetcode.com/problems/network-delay-time 相当于求单源带权最短路径。然后取所有最短路径中最大的那个。
阅读全文
posted @ 2019-08-12 13:27 fish1996
阅读(193)
评论(0)
推荐(0)
2019年8月11日
[滑动窗口] leetcode 424 Longest Repeating Character Replacement
摘要: problem:https://leetcode.com/problems/longest-repeating-character-replacement/ 维护一个最多包含k个额外字符的滑动窗口。需要记录当前出现次数最多字符的出现次数来判断窗口是否合法,如果超过了,就把首指针向后挪一位,同时更新最
阅读全文
posted @ 2019-08-11 22:14 fish1996
阅读(111)
评论(0)
推荐(0)
[滑动窗口] leetcode 76 Minimum Window Substring
摘要: problem:https://leetcode.com/problems/minimum-window-substring/ 滑动窗口题。维护一个包含t中所有字符的最小滑动窗口,首先用一个hashmap记录所有t中的字符和出现次数,在s中每遇到一次计数器加一,找到了符合条件的窗口后,尝试向右移动窗
阅读全文
posted @ 2019-08-11 21:39 fish1996
阅读(139)
评论(0)
推荐(0)
[排列] leetcode 60 Permutation Sequence
摘要: problem:https://leetcode.com/problems/permutation-sequence 求第k个排列数。数学解法,可以找一下规律。比如对于1234的排列数,一共有24种。我们从左到右依次决定排列数是哪些。首先第一个数有4种可选的,一共有24种,那么每种就是6个,我们用
阅读全文
posted @ 2019-08-11 21:18 fish1996
阅读(89)
评论(0)
推荐(0)
[排列] leetcode 46 Permutations
摘要: problem:https://leetcode.com/problems/permutations/ 输出所有排列数。递归中,最快的方法是直接交换,实际上执行的是选择操作,选择了一个数据后,把它交换到前面;可以保证下一次选择不会包含着一数字,并且数字被选择的概率都是相等的。
阅读全文
posted @ 2019-08-11 18:26 fish1996
阅读(107)
评论(0)
推荐(0)
[树] 前序,中序,后序的非递归写法
摘要: 前序遍历: 中序遍历: 后序遍历:
阅读全文
posted @ 2019-08-11 17:53 fish1996
阅读(344)
评论(0)
推荐(0)
[二分搜索] leetcode 162 Find Peak Element
摘要: problem:https://leetcode.com/problems/find-peak-element/ 根据下标二分搜索。每次检查mid左右两个数和mid的关系,决定如何进行下一步。
阅读全文
posted @ 2019-08-11 17:32 fish1996
阅读(155)
评论(0)
推荐(0)
[二分搜索] leetcode 34 Find First and Last Position of Element in Sorted Array
摘要: problem:https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ 经典二分搜索题。要点是改变low或high的时候把当前数字mid也包含进来,因为它也可能是结果。
阅读全文
posted @ 2019-08-11 16:38 fish1996
阅读(110)
评论(0)
推荐(0)
[二分搜索] leetcode 240 Search a 2D Matrix II
摘要: problem:https://leetcode.com/problems/search-a-2d-matrix-ii 经典双指针二分查找题目。
阅读全文
posted @ 2019-08-11 16:20 fish1996
阅读(102)
评论(0)
推荐(0)
上一页
1
2
3
4
5
6
···
13
下一页
公告