Resultant array Initialise all the values in resultant array with '2' except the first index of ' indices ' which is initialised as '1' Initialise maxR to store the maximum of all right values encountered so far
res = [ 2 ] * n NEW_LINE res [ indices [ 0 ] ] = 1 NEW_LINE maxR = v [ indices [ 0 ] ] [ 1 ] NEW_LINE