We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Data Structures
- Arrays
- Arrays - DS
- Discussions
Arrays - DS
Arrays - DS
Sort by
recency
|
2076 Discussions
|
Please Login in order to post a comment
This discussion post editor is very bad.
Beatifull solution with - JAVA public static List reverseArray(List a) { // Write your code here for (int i = 0; i < a.size(); i++) { a.add(a.size()-i,a.get(0)); a.remove(0); } return a; }
In python, there is only need to write for the function that would return the reverse of an array def reverseArray(a): return arr[::-1]
public static List reverseArray(List a) { List reversed = new ArrayList<>(); for(int i = a.size()-1; i >= 0; i--){ reversed.add(a.get(i)); } return reversed; }