Wednesday, January 17, 2018

Leetcode 84: Largest rectangle in histogram analysis

January 17, 2018

Introduction


It is 10:00 pm mock interview. The peer gave me the algorithm Leetcode 84: largest rectangle in histogram analysis to solve.


Algorithm analysis


The peer gave me his analysis using stack, and how to store the stack with (value, index). The discussion link is here.

Mock interview


Leetcode 84 is the hard level algorithm. I did not come out the optimal solution using time complexity O(N), and then the peer reminded me to go over upward test case like [1, 2,3, 4, 5] and then go over downward test case like [5, 4, 3, 2, 1]. And then the peer gave me the hint and then I came out using stack to push previous nodes into the stack, but I did not have idea how to manage the stack, when to push into the stack and when to pop the stack.

The peer went over quickly using the example to explain the idea.

I know that it takes me 10 mock interview practice to learn a hard level algorithm Leetcode 10: regular expression matching.

Actionable Item


Review what I did in the past on this algorithm. I did practice the algorithm in June 2015, here is the blog.



No comments:

Post a Comment