A sentence is defined as a sequence of words separated by single spaces, without any leading or trailing spaces.
Given a sentence s and an integer k, truncate s such that it contains only its first k words. Return the resulting string.
Constraints:
k is in the range
s consists of only lowercase and uppercase English letters and spaces.
The words in s are separated by a single space.
There are no leading or trailing spaces.
A sentence is defined as a sequence of words separated by single spaces, without any leading or trailing spaces.
Given a sentence s and an integer k, truncate s such that it contains only its first k words. Return the resulting string.
Constraints:
k is in the range
s consists of only lowercase and uppercase English letters and spaces.
The words in s are separated by a single space.
There are no leading or trailing spaces.