python-algorithm
leetcode 1816. Truncate Sentence
무적김두칠
2022. 3. 7. 17:30
1
2
3
4
5
6
7
|
class Solution:
def truncateSentence(self, s: str, k: int) -> str:
sList=s.split()
ans=sList[0]
for i in range(1, min(k,len(sList))):
ans=ans+' '+sList[i]
return ans
|
cs |
반응형