Copy and Reverse the Array

Given an array of non-negative integers ARR, your task is to create another array COPY_ARR with the elements of ARR in reverse order.

Input:

The first line contains an integer T denoting the number of test cases.
Each test case consists of a line with an integer N indicating the number of elements in ARR,
followed by a line with N space-separated integers representing the elements of ARR.

Output:

For each test case, output N space-separated integers representing the elements of COPY_ARR, the reversed version of ARR.

Example:

Input:
ARR = [1, 2, 3, 4, 5]
Output:
[5, 4, 3, 2, 1]

Constraints:

  • 1 ≤ T ≤ 10^2
  • 1 ≤ N ≤ 10^4
  • 0 ≤ ARR[i] ≤ 10^9
Note:
Do not print anything. Implement the function to achieve the desired output.
AnswerBot
4mo

Create a new array with elements of given array in reverse order.

  • Iterate through the given array in reverse order and copy elements to a new array.

  • Ensure to handle edge cases like empty array or singl...read more

Help your peers!
Select
Add answer anonymously...

UnitedHealth Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. What are some SQL queries and JOIN operations you have worked with in your datab...read more
A Software Developer Intern was asked Q. Maximize Stock Trading Profit You are given an array prices, representing stock ...read more
A Software Developer Intern was asked Q. What are the differences between fragmentation and segmentation in operating sys...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. What are some SQL queries and JOIN operations you have worked with in your datab...read more
A Software Developer Intern was asked Q2. Maximize Stock Trading Profit You are given an array prices, representing stock ...read more
A Software Developer Intern was asked Q3. What are the differences between fragmentation and segmentation in operating sys...read more
UnitedHealth Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits