Reverse the array
Given an array with N elements, the task is to reverse all the array elements and print the reversed array.
Input Format:
The first line contains an integer N representing the size of the array.
The second line contains N space-separated integers representing the elements of the array.
Output Format:
The only line of the output prints N space-separated integers representing the Reversed array elements.
Constraints:
1 <= N <= 10^3
1 <= arr[i] <= 10^9
1 <= K < N
CodingNinjas
author
2y
created new array and put last data into first and so on.
CodingNinjas
author
2y
Brute Force approach
- Initialise start and end indices with start = 0, end = N-1 where N is the total number of elements in array.
- We then run a loop while start < end and swap arr[start] with arr[end].
- F...read more
Help your peers!
Add answer anonymously...
Top HCLTech Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in HCLTech Software Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app