• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年12月17日
Leetcode: Shortest Palindrome
摘要: 本题最简单的思路是从后往前判断子串是否是回文串,然后把后面的弄到前面即可,不过这样仅仅能擦边通过测试 Brute Force: O(N^2), space O(1) DP: O(N^2), space O(N^2) KMP介绍:http://kb.cnblogs.com/page/176818/ 实 阅读全文
posted @ 2015-12-17 14:43 neverlandly 阅读(300) 评论(0) 推荐(0)
Leetcode: Combination Sum III
摘要: ind all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a... 阅读全文
posted @ 2015-12-17 12:56 neverlandly 阅读(262) 评论(0) 推荐(0)
Leetcode: House Robber II
摘要: Analysis: if the last one is not robbed, then you are free to choose whether to rob the first one. you can break the circle by assuming the first hous 阅读全文
posted @ 2015-12-17 12:20 neverlandly 阅读(337) 评论(0) 推荐(0)
Leetcode: Contains Duplicate II
摘要: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the ... 阅读全文
posted @ 2015-12-17 07:44 neverlandly 阅读(198) 评论(0) 推荐(0)
Leetcode: Kth Largest Element in an Array
摘要: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For examp... 阅读全文
posted @ 2015-12-17 07:30 neverlandly 阅读(347) 评论(0) 推荐(0)
Leetcode: Contains Duplicate
摘要: Use HashSet: 阅读全文
posted @ 2015-12-17 07:01 neverlandly 阅读(198) 评论(0) 推荐(0)
Leetcode: Minimum Size Subarray Sum
摘要: Haven't think about the O(nlogn) solution. O(n) solution is to maintain a window My solution: shrink as much as possible while maintaining the window 阅读全文
posted @ 2015-12-17 06:52 neverlandly 阅读(289) 评论(0) 推荐(0)
Leetcode: Add and Search Word - Data structure design
摘要: 方法1:brute force: search function compares each word with the pattern, time complexity: O(nk), n is number of words in dictionary, k is averge length 方 阅读全文
posted @ 2015-12-17 06:46 neverlandly 阅读(619) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3