by Xiaokang Zhang | Jan 23, 2017 | Algorithm & Data Structure
Maximum Subarray Problem Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] has the largest sum = 6. Reduction Transition...
by Xiaokang Zhang | Jan 23, 2017 | Algorithm & Data Structure
Largest Rectangle in Histogram Problem Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. The following is a histogram with the width of bar of 1, and...
by Xiaokang Zhang | Jan 22, 2017 | Algorithm & Data Structure
Maximal Rectangle problem Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return 6. Height, left...
by Xiaokang Zhang | Jan 22, 2017 | Economics
野生大象保护的问题 考虑一下在不同地点的一种生物:野生大象和动物园的大象。野生大象因为象牙的商业价值而濒临灭绝,相反,动物园的大象却得到很好的保护。为什么同一种生物的处境相差这么大?比较一下就会发现它们的区别: 野生大象没有主人,除了政府没有人保护,但是政府的禁令难以贯彻。偷猎野生大象的人可以获得巨大利益,成本和风险却非常小。动物园的大象属于动物园,其商业价值属于动物园,因此动物园有保护的动力。 关于野生大象的保护涉及到经济学中的另一个话题:物品的排他性和竞争性。我们先了解一下这两种属性,再回来看如何解决野生大象保护的问题。...
by Xiaokang Zhang | Jan 21, 2017 | Algorithm & Data Structure
Regular Expression Matching Problem Implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The matching should cover the...