摘要: 这里有对双向BFS 很好的解释: https://www.geeksforgeeks.org/bidirectional-search/ 双向BFS 最好的应用是 752. Open the Lock 阅读全文
posted @ 2019-02-09 02:51 KeepAC 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 在做588. Design In-Memory File System时遇到 split 函数的坑。 1. String[] strs= ”/a/b/c“.split("/") 得到的是 strs= ["","a","b","c"] 四个字符串,所以应该忽略第一个空字符串 2. String[] s 阅读全文
posted @ 2019-02-09 02:44 KeepAC 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 这三道题真是经典,值得仔细回味。 阅读全文
posted @ 2019-02-09 02:34 KeepAC 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 703 非常经典的一个题,假设有一个不断增加的序列,要求输出第K 大的数 215 太简单了,就不说了。 阅读全文
posted @ 2019-01-15 04:32 KeepAC 阅读(83) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty array of integers, return the k most frequent elements. Example 1: Example 2: Input: nums = [1], k = 1 Output: [1]非常经典的一道题,有以下几点:1. 阅读全文
posted @ 2019-01-15 03:54 KeepAC 阅读(98) 评论(0) 推荐(0) 编辑
摘要: return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). 阅读全文
posted @ 2019-01-15 03:13 KeepAC 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 280 Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3].... Example: 方法二: 上面的方法是 nlogn解法, 如何寻求一个On 的解 阅读全文
posted @ 2019-01-15 03:07 KeepAC 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 题意: 经典的递归题, 要求:除了要求 横竖都填满 1~9外, 每个3*3也都要求满足 1~9 36. 数组可以部分填充, 问是否一个有效的 sudoku. 写了个好烧脑的 四重循环来check 3*3 的部分。 重点在于 用数组作为hash 。 然后对于 check 3*3 部分, 其实就是9个小 阅读全文
posted @ 2018-11-25 05:27 KeepAC 阅读(260) 评论(0) 推荐(0) 编辑
摘要: android 解锁,规则比较复杂,其中比较复杂的是 1) 从1 到3, 如果要穿越2, 那么2必须已经走过了 分析: 1,3,7,9 是对称的, 2,4,6,8 也是对称的, 5是单独的, 因此只要从 1,3,7,9 中选 1 ,结果 x4, 从 2,4,6,8 中选2 结果x4。 最后结果就是 阅读全文
posted @ 2018-11-22 16:00 KeepAC 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 这两题 都是给定 Nums =[1 2 3] target = 4, 用nums 求和构建 target , 求出可能结果 不同点: 39 题: 认为 [1,1,2] 和 [2,1,1] 是重复结果 377 认为 [1,1,2] 和 [2,1,1] 是不同的结果。 因此画出两个题目的dfs tree 阅读全文
posted @ 2018-11-22 04:40 KeepAC 阅读(218) 评论(0) 推荐(0) 编辑