821 Shortest Distance to a Character/838 Push Dominoes
摘要:类似于 two points 的解法,非常好的指导思想。 和 821 Shortest Distance to a Character的解题思路是一样的。 题目可以转换成 数组中某个点 到特定字母的最小距离 比如 loveleetcode 求到字母e的最小距离 难点: 字母有可能出现在当前index
阅读全文
posted @
2019-10-03 02:14
KeepAC
阅读(149)
推荐(0)
826. Most Profit Assigning Work
摘要:这题讲的是 每个worker 只能做比他能力难度小的或者一样的工作, 每个工作创造的价值不同,为workers 们能创造的最高价值。 比如worker0 = 4, diff = {1,3,4} profit= {100,10,10} 那这个worker 显然要挑选 100这个高的profit 去做。
阅读全文
posted @
2019-09-30 02:51
KeepAC
阅读(191)
推荐(0)
11 Container With Most Water 42.Trapping Rain Water
摘要:11 和 42 本质上都是木桶原理: 11 如何才能存最多的水? 假设 a[left] < a[right] , total = a[left] *(right-left) , 那么 right -1, right-2 位置 都比 total 小, 此时就没必要move right 了, 因为所有的
阅读全文
posted @
2019-09-29 05:12
KeepAC
阅读(174)
推荐(0)
392 Is Subsequence 521/522. Longest Uncommon Subsequence II 524. Longest Word in Dictionary through Deleting
摘要:392 是一个easy题, 就是问 s 是否能由t 构成。 当然不能把 t 的 所有2^n个子串都拿出来,一一和s比较。 只需要two points就行了。 Example 1:s = "abc", t = "ahbgdc" 这道题很简单,但写出的code 可能差别很大,看看我第一次提交的code
阅读全文
posted @
2019-09-27 15:33
KeepAC
阅读(147)
推荐(0)