Largest Rectangle in histogram O(n^2) solution, works in small set, large set failed in memory