pieces. They are written around a circle in the given order, so the last word is followed by the first one again. Before that, each word may be kept as is or reversed, independently of the others.
Then the ring is cut at one spot and read clockwise from the cut, giving an ordinary string of the same length.
Return the lexicographically largest string you can get this way.pieces=['ram', 'top'] → 'trampo'
Keep ram as is and flip top into pot. Cut the ring rampot right before its last letter t and read on around the circle: trampo.
pieces=['bca'] → 'cba'
A single word forms the ring on its own. Flip it to acb and cut before c to get cba.
pieces=['ab', 'zc', 'b'] → 'zcbba'
pieces=['ram', 'top']
'trampo'
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.