|
|
back to boardHow do you solve this problem? Re: How do you solve this problem? Let's construct the resulting sequence from N to 1 by keeping merged segments in stack. What is the condition for merging two segments? They are touching by one of the sides (r_1+1=l_2 or r_2+1=l_1). The last part of the solution is trivial (make a tree of merges, ...). |
|
|