Created
April 12, 2023 14:01
-
-
Save Caesar-Victory/677000356b0ad3ba802b68e69fbc9ca5 to your computer and use it in GitHub Desktop.
#C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto getWords = [&](string &sentence) -> vector<string> { | |
| int n = sentence.size(); | |
| vector<string> ans; | |
| for (int i = 0; i < n; i++) { | |
| string word=""; | |
| int j = i; | |
| while (j < n && (!isblank(sentence[j]))) { | |
| word += sentence[j]; | |
| j ++; | |
| } | |
| ans.push_back(word); | |
| i = j; | |
| } | |
| return ans; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment