package leetcode;

/**
 * https://leetcode.com/problems/truncate-sentence/
 */
public class Problem1816 {
    public String truncateSentence(String s, int k) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1816 prob = new Problem1816();
        System.out.println(prob.truncateSentence("Hello how are you Contestant", 4)); // "Hello how are you"
        System.out.println(prob.truncateSentence("What is the solution to this problem", 4)); // "What is the solution"
        System.out.println(prob.truncateSentence("chopper is not a tanuki", 5)); // "chopper is not a tanuki"
    }
}

@@ -165,473 +165,286 @@
     
-// TODO%0A        return null
+String%5B%5D words = s.split(%22%5C%5Cs%22);%0A        StringBuilder answer = new StringBuilder()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1816 prob = new Problem1816();%0A        System.out.println(prob.truncateSentence(%22Hello how are you Contestant%22, 4)); // %22Hello how are you%22%0A        System.out.println(prob.truncateSentence(%22What is the solution to this problem%22, 4)); // %22What is the solution%22%0A        System.out.println(prob.truncateSentence(%22chopper is not a tanuki%22, 5)); // %22chopper is not a tanuki%22
+for (int i = 0; i %3C k; i++) %7B%0A            if (i %3E 0) %7B%0A                answer.append(%22 %22);%0A            %7D%0A            answer.append(words%5Bi%5D);%0A        %7D%0A        return answer.toString();
 %0A   

Solve problem 1816