摘要:A simple greedy construction procedure: - Fill out the seq of 'I' with 0, 1, 2, 3... - Similarly, for the seq of 'D', fill it out with n, n - 1, n - 2
阅读全文
随笔分类 - LeetCode
摘要:1AC - Yay! A super cute one : ) Again, simulate & play with it in your mind, and you will get it. Key: for car[i] at its position, it can only pass th
阅读全文
摘要:This is a super fun problem to think. Again - let's bring our ultimate tool to start playing with it - DISCRETE THINKING, STEP BY STEP. 1. [3,2] is tr
阅读全文
摘要:A different approach to the problem, besides the popular math solution.
阅读全文
摘要:A variation of 'maximum sum of subarray' - using hashmap
阅读全文
摘要:Play it in your mind.. or it may be hard to reach to this intuitive solution...
阅读全文
摘要:My first try was very close to a final solution .. however, this is a much neater solution: https://discuss.leetcode.com/topic/69436/concise-c-o-1-sol
阅读全文
摘要:Medium? Seriously? Well again, always smart solutions out there: https://discuss.leetcode.com/topic/77889/3-line-python-solution
阅读全文
摘要:Isn't it 'Easy'?
阅读全文
摘要:It is a matter of hashmap use. For the follow-up:
阅读全文
摘要:A more programming-like solution, is to hack the problem from simple: we try each possble base value, and see which 111..11 fits target number - using
阅读全文
摘要:Check out this brilliant solution:https://discuss.leetcode.com/topic/70658/concise-java-solution-using-dp My first solution was a O(n^2) typical DP bo
阅读全文
摘要:The punch line of this one: sum of leaves: pi..pj = root..pj - root..pi.
阅读全文
摘要:Split it into 2 group of arrays, 2 arrays in each group. Then use hashmap. class Solution { public: int fourSumCount(vector<int>& A, vector<int>& B, v
阅读全文
摘要:A natural stack based solution. Seriously, whey 'Medium'? /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; *
阅读全文
摘要:Check this out: https://discuss.leetcode.com/topic/76312/java-1-line-recursion-solution Neat thoughts with neat code. Bravo. Deserve to learn.
阅读全文
摘要:Simple greedy thought .. satify each kid with minimum qualified cookie, from the least greedy kid..
阅读全文
摘要:Idea is, among all factors of the int, we pick the two that is the closest pair. And searching from sqrt(area) is a better idea: https://discuss.leetc
阅读全文
摘要:I prefer shorter code, so this one:https://discuss.leetcode.com/topic/75448/memoization-c-solution Please note: we don't want to be too greedy - despe
阅读全文
摘要:Yes the most concise solution is recursion.https://discuss.leetcode.com/topic/66165/very-concise-c-solution-for-general-binary-tree-not-only-bst Here
阅读全文

浙公网安备 33010602011771号