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:
Matej Focko 2025-02-04 21:20:29 +01:00
parent 747f728dc9
commit a28c619756
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,3 @@
class Solution {
fun reverseWords(s: String): String = s.trim().split(Regex("\\s+")).reversed().joinToString(" ")
}