• LeetCode "332. Reconstruct Itinerary"

    LeetCode link Intuition Using DFS to recursion the path. And build a map that save the dep. and arr. airports. The value in the map is a minHeap to ensure th...

    LeetCode "295. Find Median from Data Stream"

    LeetCode link Intuition Using two heaps, maxHeap and minHeap, ensure the size of max always not smaller the min, so the median is the max peek(when max is on...

    LeetCode "215. Kth Largest Element in an Array"

    LeetCode link Intuition Using minHeap to save the top k largest numbers, and the root is the kth largest number. solution 12345678910111213141516171819class...

    LeetCode "239. Sliding Window Maximum"

    LeetCode link Intuition Using a heap to maintain the index, remove and add the borders, and add the peek value to the final result. solution 123456789101112...

    LeetCode "23. Merge k Sorted Lists"

    LeetCode link Intuition Using a minHeap to maintain all the values, and poll out. The previous solution may meet a MLE. Because the input lists may be a huge...

    LeetCode "213. House Robber II"

    LeetCode link Intuition Same as House Robber, just aware when pick the last number, the first one cannot be selected, so the range is 1 to n - 2 solution 12...

    LeetCode "120. Triangle"

    LeetCode link Intuition Try DFS. Maybe have a TLE. solution 123456789101112131415161718192021222324class Solution { int min = Integer.MAX_VALUE; ...

    LeetCode "496. Next Greater Element I"

    LeetCode link Intuition Using a descending stack to maintain the numbers. When the current number is larger than the top, this number is the next-greater-ele...

    LeetCode "42. Trapping Rain Water"

    LeetCode link Intuition Descending stack. When height[i] > top, pop stack and calculate the sum. How to calculate the sum: assume the height[i] is the bor...

    POJ "3250 Bad Hair Day"

    POJ link first thought Using monotonic stack(I’m not sure whether this translation is correct). Monotonic stack is calculate the sum when popping out a numbe...