On an infinite number line (x-axis), we drop given squares in the order they are given.
The i-th square dropped (A[i] = (left, side_length)) is a square with the left-most point being A[i] and
side length A[i].
The square is dropped with the bottom edge parallel to the number line, and from a higher height than all currently
landed squares. We wait for each square to stick before dropping the next.
The squares are infinitely sticky on their bottom edge, and will remain fixed to any positive length surface they touch
(either the number line or another square). Squares dropped adjacent to each other will not stick together prematurely.
Given A, find and return a list of heights H. Each height H[i] represents the current highest height of any
square we have dropped, after dropping squares represented by A, A, …, A[i].
The only argument given is the integer matrix A.
Return the array H.
1 <= length of the array A <= 1000 1 <= A[i] <= 10^8 1 <= A[i] <= 10^6
Input 1: A = [[1, 2], [2, 3], [6, 1]] Output 1: [2, 5, 5] Input 2: A = [[100, 100], [200, 100]] Output 2: [100, 100]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.