Recursive Sentence Reverser
easy
StringRecursionDfs Recursive
Asked atMicrosoftAmazon
Problem Description
Given a sentence string `text` containing words separated by single spaces, return the sentence with the word order reversed. You must implement the reversal using recursion — do **not** use built-in reverse functions.
**Example 1:**
```
Input: text = "the quick brown fox"
Output: "fox brown quick the"
```
**Example 2:**
```
Input: text = "hello world"
Output: "world hello"
```
Constraints
- 1 <= text.length <= 10000
- text contains only lowercase English letters and single spaces
- text does not have leading or trailing spaces
- Words are separated by exactly one space
Hints
Try the problem first. If you get stuck, you can reveal hints one at a time.
Solution
Leaderboard
No entries yet for python.
Be the first — submit an accepted solution.