As reported: Intuit SWE-2 (Bangalore, 2025), onsite DSA + HLD round (60 min): reverse the words in a string in place, in Java, with no extra space.
A sentence is stored as a character array s. Words are separated by single spaces; there are no leading or trailing spaces. Reverse the order of the words in place, using O(1) extra space.
This is LeetCode 186 — Reverse Words in a String II.
Examples
["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"]
-> ["b","l","u","e"," ","i","s"," ","s","k","y"," ","t","h","e"]
["a"] -> ["a"]
Constraints: 1 ≤ s.length ≤ 10^5; s[i] is a letter, digit or space; at least one word; single spaces between words.
Code runner format: one JSON value per line (LeetCode's test-case format): s as an array of one-character strings. Implement reverseWords(s), which modifies s in place; the harness prints s afterwards.