53. Reverse the words
Write reverseWords s: the words of s in reverse order, separated by single spaces. Words are separated by one or more spaces, and s may start or end with spaces, which do not appear in the result.
Examples
- Input
reverseWords "the sky is blue"Output"blue is sky the" - Input
reverseWords " hello world "Output"world hello"
Submitting also runs 5 hidden tests.
Loading editor…
Type
\to in the editor, or click:Run checks your code against the examples and your custom inputs and records nothing. Submit also runs the hidden tests, confirms the axioms your proof uses and records the result. Each uses one compiler check.
ReadyLn 1, Col 1Lean 4
Draft saved in this browser