FastPrepReverse String
Problems/Reverse String

Reverse String

Zillow logoZillow● EasyFULLTIMEOAPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Asked at Zillow from 2015 to 2019. Two reports place it in a phone screen, each time as one of two coding questions. The third lists it as one of two tasks in a coding test taken before a phone interview, next to a tree task. One phone screen report comes from a software engineer with 9 years of experience; the other two candidates gave no level.

One phone screen report points to the well-known version of this task: reverse an array of characters in place, using O(1) extra memory, for 1 to 10^5 printable ASCII characters. We use that version and its limits. In the 2016 phone screen report the candidate gave several ways to solve the two questions and went over their time and memory costs. Neither that report nor the coding test report says whether it had to be done in place or what the input looked like, so we assume the same version for them. The function gets the string as an array of characters; returning that same array after the reversal is our addition, so the result can be checked.

Our version is about 90% the same as the reported question.

You are given a string as an array of characters s. Reverse the order of the characters in place and return the same array.

Change the input array itself and use only O(1) extra memory: do not build a second array or string whose size grows with the input.

Function

reverseString(s: char[]) → char[]

Examples

Example 1

s = ["Z","i","l","l","o","w"]return = ["w","o","l","l","i","Z"]

Swap the first and last characters, then the second and second-to-last, then the third and third-to-last: Z with w, i with o, and l with l.

Example 2

s = ["a","b","c","d","e"]return = ["e","d","c","b","a"]

The length is odd, so the middle character c has no partner and stays where it is. Only a with e and b with d are swapped.

Example 3

s = ["Q"]return = ["Q"]

A single character is its own reverse; there is nothing to swap.

Example 4

s = ["H","i",","," ","4","2","!"]return = ["!","2","4"," ",",","i","H"]

Spaces, digits and punctuation are characters like any other. The space is the middle character, so it stays where it is, and the ! at the end becomes the first character.

Constraints

  • 1 <= s.length <= 105
  • Each s[i] is a printable ASCII character (character codes 32 to 126), so it can be a letter, a digit, a space or a symbol.

More Zillow Phone Screen questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Time Based Key-Value StorePHONE SCREEN · Seen Feb 2024
  • Filter Formatted Records by CriteriaPHONE SCREEN · Seen Sep 2023
  • Build a Hash TablePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Jump GamePHONE SCREEN · Seen Dec 2022
  • Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
  • Spiral MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2022
  • Two Sum: All PairsPHONE SCREEN · Seen Nov 2022
  • Employee Free TimePHONE SCREEN · Seen Oct 2022
  • First Unique Character in a StringPHONE SCREEN · Seen Oct 2022

Similar questions at other companies

  • Run-Length Encoding and DecodingAirbnb · PHONE SCREENAirbnb interview questions
  • Check if a String Is a PalindromeCisco · PHONE SCREENCisco interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Reverse a StringAmazon · PHONE SCREEN
  • Reverse a String ManuallyNewgen Software · PHONE SCREEN
  • Reverse a String with Two PointersSnowflake · PHONE SCREENSnowflake interview questions
  • Palindrome with One DeletionWhatNot · PHONE SCREENWhatNot interview questions
  • Valid Word AbbreviationMeta · PHONE SCREENMeta interview questions
  • Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
  • Alternate String EndsCapital One · OACapital One interview questions
All Zillow interview questionsSee Zillow hiring insights
Saved
class Solution {
    public char[] reverseString(char[] s) {
        // Write your code here.
    }
}
Checking account…