FastPrepCorrect an In-Place Array Reversal
Problems/Correct an In-Place Array Reversal

Correct an In-Place Array Reversal

Duolingo logoDuolingo● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report points out the double-swap bug in an in-place reversal and the fix of only going through the first half. Our version is about 99% the same as the reported question.

A proposed reversal loops over every index and swaps each element with its mirror. That swaps every pair twice and restores the original array.

Given nums, reverse it in place by swapping each mirrored pair exactly once, then return the same array.

Function

reverseArray(nums: int[]) → int[]

Examples

Example 1

nums = [1,2,3,4]return = [4,3,2,1]

Swap indices 0 and 3, then 1 and 2.

Example 2

nums = [7]return = [7]

A one-element array is already reversed.

Constraints

  • 0 <= nums.length <= 100000
  • -1000000000 <= nums[i] <= 1000000000
  • Use O(1) extra space.

More Duolingo Phone Screen questions

  • Group Timestamps into Consecutive-Day IntervalsPHONE SCREEN · Seen Nov 2026
  • Return Every Matching DecryptionPHONE SCREEN · Seen Nov 2026
  • Visit Desired Attractions Without Reusing a TrailPHONE SCREEN · Seen Oct 2026
  • Count Starts Reaching a Grid MaximumPHONE SCREEN · Seen Oct 2026
  • Select the Top User MatchesPHONE SCREEN · Seen Oct 2026
  • Sum All Values in a Binary TreePHONE SCREEN · Seen Oct 2026
  • User Resource Transition ProbabilitiesPHONE SCREEN · Seen Oct 2026
  • Encrypt and Decrypt StringsPHONE SCREEN · Seen Apr 2026
  • Validate a Mahjong Hand PartitionPHONE SCREEN · Seen Nov 2025
  • Directional Tiles: Find a Valid Reconfiguration PathPHONE SCREEN · Seen Oct 2022

Similar questions at other companies

  • Compact Conversation History by Token BudgetSierra · PHONE SCREENSierra interview questions
  • Remove Duplicates from Sorted ArrayNykaa · PHONE SCREENNykaa interview questions
  • Minimum Index Distance Between Person and CakeSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Squares of a Sorted ArrayInstacart · PHONE SCREENInstacart interview questions
  • Closest Vehicle and Charger in a LineSpotify · PHONE SCREEN
  • Assign CookiesAmazon · PHONE SCREEN
  • Remove Duplicates From Sorted Array In PlaceKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Merge Two Sorted ArraysCapgemini · PHONE SCREENCapgemini interview questions
  • Remove Duplicates From Sorted Array In PlaceGet My Parking · PHONE SCREEN
  • Deduplicate a Sorted Array In PlaceGEP · PHONE SCREEN

Interview reports that mention this question

  • Duolingo SWE Interview Questions: 3 Experiences

Duolingo interview experiences

  • Duolingo interviews · November 2026
All Duolingo interview questionsSee Duolingo hiring insights
Saved
class Solution {
    public int[] reverseArray(int[] nums) {
        // Write your code here.
    }

}
Checking account…