FastPrepReverse Word Order In Place
Problems/Reverse Word Order In Place

Reverse Word Order In Place

Microsoft logoMicrosoft● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft phone screen. The report asks to reverse the order of words in place, but leaves open the rules for spaces and characters. Our version is about 90% the same as the reported question.

Given a mutable character array chars representing a sentence, reverse the order of its words while keeping the characters inside each word in their original order. Modify the supplied array in place using constant auxiliary workspace, then return the same array.

Every word contains ASCII letters. Adjacent words are separated by exactly one ASCII space, with no leading or trailing space. An empty array represents an empty sentence.

Function

reverseWordOrderInPlace(chars: char[]) → char[]

Examples

Example 1

chars = ["s","k","y"," ","i","s"," ","b","l","u","e"]return = ["b","l","u","e"," ","i","s"," ","s","k","y"]

Reverse three words without reversing their letters.

Example 2

chars = ["M","L"]return = ["M","L"]

A single word has no word-order change.

Example 3

chars = []return = []

The empty character array has no words.

Constraints

  • 0 <= chars.length <= 2000.
  • Each nonempty word contains only A-Z or a-z.
  • Words are separated by one space and there are no leading or trailing spaces.

More Microsoft Phone Screen questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Corporation Reporting LinesPHONE SCREEN · Seen Oct 2026
  • Random Forest Classifier from ScratchPHONE SCREEN · Seen Oct 2026
  • Least Recently Used CacheOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Greedy and Beam Sentence DecodingPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Sep 2026
  • 3SumPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Arithmetic Expression EvaluatorPHONE SCREEN · Seen Sep 2026
  • Employee Hierarchy Cycle and Depth AnalysisPHONE SCREEN · Seen Sep 2026
  • Most Visited String SectorsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Add Signed Character ArraysByteDance · PHONE SCREEN
  • Objects Seen on Both Days by Multiple ClientsGoogle · PHONE SCREEN
  • Reverse the Interior of Vowel-Bounded WordsVisa · OA
  • Reverse the Interior of Vowel-Bounded WordsZipRecruiter · OA
  • Rank Word-Translation Hints from Sentence TranslationsDuolingo · PHONE SCREEN · ONSITE INTERVIEW
  • Linked Merchants Within Two HopsStripe · PHONE SCREEN
  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEW
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREEN · ONSITE INTERVIEW
  • Run-Length Encoded Vector Dot ProductMeta · PHONE SCREEN · ONSITE INTERVIEW
  • Interval List IntersectionsGrammarly · PHONE SCREEN
See Microsoft hiring insights
Saved
class Solution {
    public char[] reverseWordOrderInPlace(char[] chars) {
        // Reverse the word order in place.
    }
}
Checking account…