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... 阅读全文
posted @ 2015-11-23 17:14 jianchao-li 阅读(1497) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-11-20 13:16 jianchao-li 阅读(862) 评论(0) 推荐(0) 编辑
摘要:Problem Description:A 2d grid map ofmrows andncolumns is initially filled with water. We may perform anaddLandoperation which turns the water at posit... 阅读全文
posted @ 2015-11-14 20:55 jianchao-li 阅读(7298) 评论(0) 推荐(0) 编辑
摘要: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 ... 阅读全文
posted @ 2015-11-12 22:00 jianchao-li 阅读(668) 评论(0) 推荐(0) 编辑
摘要:The idea is fairly straightforward: create an arrayaccuthat stores the accumulated sum fornumssuch thataccu[i] = nums[0] + ... + nums[i]in the initial... 阅读全文
posted @ 2015-11-10 13:43 jianchao-li 阅读(989) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-11-08 21:00 jianchao-li 阅读(1280) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-11-05 15:38 jianchao-li 阅读(1429) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-11-03 22:15 jianchao-li 阅读(404) 评论(1) 推荐(0) 编辑