原题
直接按空格切分,然后取前k个
class Solution: def truncateSentence(self, s: str, k: int) -> str: strs = s.split(' ') return ' '.join(strs[:k])
最后更新于3年前