Reverse Words in a String (Preserve Spaces, In-Place)
Asked at ByteDance · Coding Questions · Difficulty: Medium · Last asked Mar 10, 2026
Reverse the word order in a string. A word is a maximal substring of non-space characters. The canonical formulation trims leading/trailing whitespace and collapses internal runs of spaces to a single space.
Loading the problem…
More ByteDance interview questions
- Project Deep Dive (Resume Drill)
- Video-Keyword Association Review System
- Realtime Auction Bidding System
- MLE Oral Fundamentals: Dropout, Overfitting, Normalization, Loss Functions
- Content Moderation System Design
- ML System Design: Dynamic K in Retrieval Stage