You are viewing a single comment's thread. Return to all comments →
I've done it :) Passing all test :) My approach is:
Prep stage:
Algo stage:
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)
Seems like cookies are disabled on this browser, please enable them to open this website
Lily's Homework
You are viewing a single comment's thread. Return to all comments →
I've done it :) Passing all test :) My approach is:
Prep stage:
Algo stage:
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)