You are viewing a single comment's thread. Return to all comments →
I've done it :) Passing all test :) My approach is:
Iterate through input list, and compare current value (lets call it cv) against value from sorted list (lets call it scv). If it is diffrent:
Then you need to execute it on input list and reversed input list - the smaller return value - is the answer.
Time complexity is equal to sort time complexity (usually O(n logn) ). Space O(n)