• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2016年12月3日
Leetcode: Find All Anagrams in a String
摘要: Time Complexity will be O(n) because the "start" and "end" points will only move from left to right once. Sliding Window: Use a count to denote the di 阅读全文
posted @ 2016-12-03 13:14 neverlandly 阅读(1403) 评论(0) 推荐(0)
Leetcode: Pacific Atlantic Water Flow
摘要: 这题考点在于需要设置两个visited数组 Two Queue and add all the Pacific border to one queue; Atlantic border to another queue. Keep a visited matrix for each queue. I 阅读全文
posted @ 2016-12-03 12:05 neverlandly 阅读(799) 评论(0) 推荐(0)
Leetcode: Partition Equal Subset Sum
摘要: Backpack problem: dp[i][j] means if the first i elements can sum up to value j dp[i][j] = dp[i-1][j] || (j>=nums[i-1] && dp[i-1][j-nums[i-1]]) the res 阅读全文
posted @ 2016-12-03 10:29 neverlandly 阅读(309) 评论(0) 推荐(0)
Leetcode: Third Maximum Number
摘要: My Solution: Highest votes in discussion 阅读全文
posted @ 2016-12-03 06:22 neverlandly 阅读(374) 评论(0) 推荐(0)
Leetcode: Arithmetic Slices
摘要: A slice (P, Q)其实就是从P到Q的序列,(P,Q)是arithmetic slice要求是等差数列且至少有三个数,问array里面有多少个这样的(P, Q) 这道题难点在于想到用DP,一旦想到用DP,就迎刃而解 dp[i]表示以i结束的slice有多少个 阅读全文
posted @ 2016-12-03 05:12 neverlandly 阅读(372) 评论(0) 推荐(0)
Leetcode: Trapping Rain Water II
摘要: The above image represents the elevation map [[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]] before the rain. After the rain, water are trapped between th 阅读全文
posted @ 2016-12-03 03:16 neverlandly 阅读(558) 评论(0) 推荐(0)
Leetcode: Remove K Digits
摘要: Greedy + Stack: 用一个栈维护最后要留存下来的digits 需要注意的是:如果遍历到string的某个char, string后面的char数刚刚好能填满这个栈,那么即使这个char比栈顶还要小,也不出栈,直接入栈 最后要删除leading 0 用char[]实现栈,思路一样,要快很多 阅读全文
posted @ 2016-12-03 00:24 neverlandly 阅读(439) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3