摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
Check this out: https://discuss.leetcode.com/topic/76312/java-1-line-recursion-solution Neat thoughts with neat code. Bravo. Deserve to learn. 阅读全文
摘要:
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 阅读全文
摘要:
This problem reflects a key strategy when dealing with discrete problem space - split split split.. That' is to say, we check each house and find its 阅读全文
摘要:
Brutal force works - and a smarter way is to utilize KMP. The most popular two solutions are essentially the same - one is obvious KMP, and another on 阅读全文