package leetcode;

/**
 * https://leetcode.com/problems/number-of-segments-in-a-string/
 */
public class Problem434 {
    public int countSegments(String s) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem434 prob = new Problem434();
        System.out.println(prob.countSegments("Hello, my name is John")); // 5
    }
}

@@ -164,16 +164,38 @@
     
-// TODO%0A
+if (s.trim().isEmpty()) %7B%0A    
     
@@ -216,178 +216,59 @@
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem434 prob = new Problem434();%0A        System.out.println(prob.countSegments(%22Hello, my name is John%22)); // 5
+%7D%0A        return s.trim().split(%22%5C%5Cs+%22).length;
 %0A   

Solve problem 434