This was originally a question from interviewstreet.com over a decade ago You are given an array (or whatever - your choice of input) of positive integers \$y_1,\ldots,y_n\$ that represents \$n\$ line segments, where segment \$i\$ has endpoints \$(i, 0)\$ and \$(i, y_i)\$. Imagine that from the top of each segment a horizontal ray is shot to the left, and this ray stops when it touches another segment or it hits the \$y\$-axis. Construct an array of \$n\$ integers, \$v_1,\ldots,v_n\$, where \...