As reported: Autodesk SDE 1 loop (C++, 2025), round 1: an easy problem — split a sentence into words, e.g.
"Tommy is good dog"→Tommy,is,good,dog— with edge cases, run locally against the interviewer's test cases.
Given a string sentence, return the list of its words in order. A word is a maximal run of non-space characters; words are separated by one or more space characters ' '. The sentence may start or end with spaces, and may be empty or contain only spaces.
Write the splitting yourself — do not call a library split.
Example 1
sentence = "Tommy is good dog" -> ["Tommy","is","good","dog"]
Example 2
sentence = " hello world " -> ["hello","world"]
Example 3
sentence = " " -> []
Constraints: 0 ≤ sentence.length ≤ 10^5; sentence holds ASCII characters; only ' ' separates words (punctuation and tabs stay part of a word).
Code runner format: one line holding sentence as a JSON string. Implement splitWords(sentence); the harness prints the list of words.