• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅

随笔分类 -  Leetcode

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 32 下一页
Leetcode: Minimum Domino Rotations For Equal Row

摘要:1. The final uniform character should be either A[0] or B[0] 2. A[0] could be at the top, or the bottom. Same applies to B[0] 3. If A[0] works, no nee 阅读全文
posted @ 2019-10-01 13:27 neverlandly 阅读(476) 评论(0) 推荐(0)
Leetcode: Palindromic Substrings

摘要:DP: Extend palindrome: (better) 阅读全文
posted @ 2019-09-30 13:59 neverlandly 阅读(172) 评论(0) 推荐(0)
Leetcode: Subtree of Another Tree

摘要:Recursion: 阅读全文
posted @ 2019-09-20 15:17 neverlandly 阅读(155) 评论(0) 推荐(0)
Leetcode: Longest Common Subsequence

摘要:DP with a 2D array Time & space: O(m * n) (Skim through) memory optimization, referencing: https://leetcode.com/problems/longest-common-subsequence/di 阅读全文
posted @ 2019-09-17 13:56 neverlandly 阅读(212) 评论(0) 推荐(0)
Leetcode: Encode and Decode TinyURL

摘要:1. 根据系统设计的Estimation of the amount of data we need to store for the next couple of years, 我们应需要6位Base62的char来encode 2. assume 避免地址爆炸,相同的longUrl得到相同的sh 阅读全文
posted @ 2017-03-11 04:30 neverlandly 阅读(4086) 评论(1) 推荐(0)
Leetcode: The Maze III(Unsolved Lock Problem)

摘要:Each time, first add the direction to the path, and then go with that direction, checking for hole along the way. When hit a wall, try to turn, and go 阅读全文
posted @ 2017-02-14 02:45 neverlandly 阅读(843) 评论(0) 推荐(0)
Leetcode: The Maze II

摘要:Solution of The Maze: https://discuss.leetcode.com/topic/77471/easy-understanding-java-bfs-solutionSolution of The Maze III: https://discuss.leetcode. 阅读全文
posted @ 2017-02-14 02:43 neverlandly 阅读(1306) 评论(0) 推荐(0)
Leetcode: The Maze(Unsolved locked problem)

摘要:Search in the four possible directions when coming to a stopping point (i.e. a new starting point). Keep track of places that you already started at i 阅读全文
posted @ 2017-02-14 02:36 neverlandly 阅读(611) 评论(0) 推荐(0)
Leetcode: Max Consecutive Ones II(unsolved locked problem)

摘要:未研究: The idea is to keep a window [l, h] that contains at most k zero The following solution does not handle follow-up, because nums[l] will need to a 阅读全文
posted @ 2017-02-14 01:40 neverlandly 阅读(413) 评论(0) 推荐(0)
Leetcode: Find Permutation(Unsolve lock problem)

摘要:还没研究: For example, given IDIIDD we start with sorted sequence 1234567Then for each k continuous D starting at index i we need to reverse [i, i+k] port 阅读全文
posted @ 2017-02-14 01:36 neverlandly 阅读(489) 评论(0) 推荐(0)
Leetcode: Sliding Window Median

摘要:方法1:Time Complexity O(NK) 暂时只有两个Heap的做法,缺点:In this problem, it is necessary to be able remove elements that are not necessarily at the top of the heap 阅读全文
posted @ 2017-01-24 05:24 neverlandly 阅读(746) 评论(0) 推荐(0)
Leetcode: Number Complement

摘要:Better solution: Returns an int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int va 阅读全文
posted @ 2017-01-23 23:54 neverlandly 阅读(329) 评论(0) 推荐(0)
Leetcode: LFU Cache && Summary of various Sets: HashSet, TreeSet, LinkedHashSet

摘要:referred to: https://discuss.leetcode.com/topic/69137/java-o-1-accept-solution-using-hashmap-doublelinkedlist-and-linkedhashset Two HashMaps are used, 阅读全文
posted @ 2016-12-24 03:43 neverlandly 阅读(577) 评论(0) 推荐(0)
Leetcode: Poor Pigs

摘要:My binary encoding method gives a 8 for the first problem, however, there is a smarter method that generates a answer of 5, which can be found here: h 阅读全文
posted @ 2016-12-23 11:37 neverlandly 阅读(1107) 评论(0) 推荐(0)
Leetcode: Validate IP Address

摘要:Be careful, split() will not include trailing empty strings in the result array The string "boo:and:foo", for example, split(":")的结果是 {“boo”, "and", " 阅读全文
posted @ 2016-12-23 08:44 neverlandly 阅读(1086) 评论(0) 推荐(0)
Leetcode: Encode String with Shortest Length && G面经

摘要:DP: Initially I think of 1D DP, dp[i] stands for the shortest string of first i characters, then: dp[i] = minLen{dp[k] + encode(substring(k+1, i))} th 阅读全文
posted @ 2016-12-23 06:25 neverlandly 阅读(2169) 评论(0) 推荐(0)
Leetcode: Concatenated Words

摘要:Scan through array and DP: We iterate through each word and see if it can be formed by using other words. The subproblem is Word Break I. But it is a 阅读全文
posted @ 2016-12-23 01:40 neverlandly 阅读(1336) 评论(0) 推荐(0)
Leetcode: Convex Polygon

摘要:https://discuss.leetcode.com/topic/70706/beyond-my-knowledge-java-solution-with-in-line-explanation https://discuss.leetcode.com/topic/70664/c-7-line- 阅读全文
posted @ 2016-12-22 13:14 neverlandly 阅读(962) 评论(0) 推荐(0)
Leetcode: Unique Substrings in Wraparound String

摘要:这道题我一开始发现了数学规律: length of consecutive chars vs number of different substring “a” -> 1 = 1 "ab" -> 3 = 1+2 "abc" -> 6 = 1+2+3 "abcd" -> 10 = 1+2+3+4 于是 阅读全文
posted @ 2016-12-22 11:05 neverlandly 阅读(624) 评论(0) 推荐(0)
Leetcode: Count The Repetitions

摘要:目前只想出了Brute Force做法(1165ms), 看到有<20ms的做法,未深究: 阅读全文
posted @ 2016-12-22 07:24 neverlandly 阅读(662) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 32 下一页
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3