알고리즘/LeetCode
LeetCode 풀기 - 1816. Truncate Sentence
앤테바
2021. 11. 5. 20:04
반응형
1816. Truncate Sentence
https://leetcode.com/problems/truncate-sentence/
Truncate Sentence - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제)
솔루션1)
class Solution:
def truncateSentence(self, s: str, k: int) -> str:
return ' '.join(s.split()[:k])
반응형