kt: add «151. Reverse Words in a String»
URL: https://leetcode.com/problems/reverse-words-in-a-string/ Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
747f728dc9
commit
a28c619756
1 changed files with 3 additions and 0 deletions
3
kt/reverse-words-in-a-string.kt
Normal file
3
kt/reverse-words-in-a-string.kt
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Solution {
|
||||
fun reverseWords(s: String): String = s.trim().split(Regex("\\s+")).reversed().joinToString(" ")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue