You are viewing a single comment's thread. Return to all comments →
Here's an in-place solution (C#):
public static List<int> reverseArray(List<int> a) { for (int i = 0; i < a.Count / 2; i++) { a[i] = a[i]^a[a.Count - i - 1]; a[a.Count-i - 1] = a[i]^a[a.Count - i - 1]; a[i] = a[i]^a[a.Count - i - 1]; } return a; }
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 →
Here's an in-place solution (C#):