Compute the max. water trapped by a pair of vertical lines
Problem An array of integers naturally defines a set of lines parallel to the Y-axis, starting from x = 0 as illustrated in the figure above. The »
Problem An array of integers naturally defines a set of lines parallel to the Y-axis, starting from x = 0 as illustrated in the figure above. The »
Problem Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h »
Problem Given an array of integers representing stock prices, with each index representing a different day, find the maximum profit by selling at most two stocks. »
There are many definitions of greedy algorithms, but in general, they have two properties: You build the solution by finding the most optimal answer at each »