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 |
반응형
'python-algorithm' 카테고리의 다른 글
백준 21598 SciComLove (0) | 2022.03.08 |
---|---|
백준 SASA 모형을 만들어보자 (0) | 2022.03.08 |
leetcode 1688. Count of Matches in Tournament (0) | 2022.03.07 |
백준 9316 Hello Judge (0) | 2022.03.07 |
Leetcode 2006. Count Number of Pairs With Absolute Difference K (0) | 2022.03.07 |
댓글