Reverse Like Linked List
Published at25 Jul 2026
Created by M Ichsanul Fadhil
Reverse an array of elements. This simulates reversing a linked list where each element points to the next.
Example Input & Output
Example 1
Input
[1,2,3,4,5]
Output
[5,4,3,2,1]
Explanation
Reverse order
Algorithm Flow

Recommendation Algorithm Flow for Reverse Like Linked List
Solution Approach
Best Answers
java
class Solution {
public int[] solution(int[] nums) {
int[] r=nums.clone();
for(int i=0,j=r.length-1;i<j;i++,j--){int t=r[i];r[i]=r[j];r[j]=t;}
return r;
}
}Related Linked List Challenges
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
