11 2015 档案
摘要:This problem requires a new data structure --- Segment Tree. You may use this GeeksforGeeks article to get some ideas of it. However, the code in this...
阅读全文
摘要:Af first I read the title as "Addictive Number". Anyway, this problem can be solved elegantly using recursion. This post shares a nice recursive C++ c...
阅读全文
摘要:Problem Description:A 2d grid map ofmrows andncolumns is initially filled with water. We may perform anaddLandoperation which turns the water at posit...
阅读全文
摘要:Very similar to Range Sum Query - Immutable, but we now need to compute a 2d accunulated-sum. In fact, if you work in computer vision, you may know a ...
阅读全文
摘要:The idea is fairly straightforward: create an arrayaccuthat stores the accumulated sum fornumssuch thataccu[i] = nums[0] + ... + nums[i]in the initial...
阅读全文
摘要:This post shares very detailed explanation of how to use binary search to find the boundaries of the smallest rectangle that encloses the black pixels...
阅读全文
摘要:This problem can be solved very elegantly using BFS, as in this post.The code is rewritten below in C++. 1 class Solution { 2 public: 3 vector rem...
阅读全文
摘要:A typical O(n^2) solution uses dynamic programming. Let's use lens[j] to denote the length of the LIS ending with nums[j]. The state equations arelens...
阅读全文