Truncate Sentence
Easy
Strings
Array
String
Truncate string to first k words.
Constraints
1 ≤ k ≤ word count
Examples
Example 1:
Input: Hello how are you Contestant
4
Output: Hello how are you
Example 2:
Input: What is the solution
4
Output: What is the solution
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console