• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年12月18日
Leetcode: Contains Duplicate III
摘要: 暴力枚举会LTE,解题思路是用sortedSet来解决,sortedSet可以返回一个在某个范围的subSet,同时判断这个subSet是否为空即可解决,主要,本题需要使用long类型! 时间 O(NlogK) 空间 O(K) 思路 要求判断之前是否存在差值小于t的数字,我们需要知道在当前数字x两边 阅读全文
posted @ 2015-12-18 23:31 neverlandly 阅读(269) 评论(0) 推荐(0)
Leetcode: Invert Binary Tree
摘要: nvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this... 阅读全文
posted @ 2015-12-18 13:14 neverlandly 阅读(287) 评论(0) 推荐(0)
Leetcode: The Skyline Problem
摘要: 参考了http://www.cnblogs.com/tonyluis/p/4564617.html 复杂度 Time Complexity is O(n^2) because removal in a PQ is O(n), 空间 O(N) I think if replace PQ with Tr 阅读全文
posted @ 2015-12-18 12:27 neverlandly 阅读(268) 评论(0) 推荐(0)
Leetcode: Word Search II
摘要: 如果跟Word Search做法一样,还按照DFS回溯的方法,逐个检查每个word是否在board里,显然效率是比较低的。我们可以利用Trie数据结构,也就是前缀树。然后dfs时,如果当前形成的单词不在Trie里,就没必要继续dfs下去了。如果当前字符串在trie里,就说明board可以形成这个wo 阅读全文
posted @ 2015-12-18 03:22 neverlandly 阅读(533) 评论(0) 推荐(0)
Leetcode: Rectangle Area
摘要: Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as sh... 阅读全文
posted @ 2015-12-18 00:48 neverlandly 阅读(324) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3