You are viewing a single comment's thread. Return to all comments →
there is two solutions with different times Space and Time.
public static List<Integer> reverseArray(List<Integer> list) { //two pointers technique int left = 0, right = list.size() - 1; while(left < right) { int tempValue = list.get(left); list.set(left, list.get(right)); list.set(right, tempValue); left++; right--; } return list; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Arrays - DS
You are viewing a single comment's thread. Return to all comments →
there is two solutions with different times Space and Time.