package leetcode;

/**
 * https://leetcode.com/problems/number-of-lines-to-write-string/
 */
public class Problem806 {
    public int[] numberOfLines(int[] widths, String S) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem806 prob = new Problem806();
        System.out.println(prob.numberOfLines(new int[]{
            10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10},
            "abcdefghijklmnopqrstuvwxyz")); // [3, 6]
        System.out.println(prob.numberOfLines(new int[]{
            4,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10},
            "bbbcccdddaaa"
        )); // [2, 4]
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -207,35 +207,376 @@
     
-// TODO%0A        return null
+int%5B%5D result = new int%5B2%5D;%0A        result%5B0%5D = 1;%0A        int count = 0;%0A        for (char c : S.toCharArray()) %7B%0A            if (count + widths%5Bc - 'a'%5D %3E 100) %7B%0A                count = widths%5Bc - 'a'%5D;%0A                result%5B0%5D++;%0A            %7D else %7B%0A                count += widths%5Bc - 'a'%5D;%0A            %7D%0A        %7D%0A        result%5B1%5D = count;%0A        return result
 ;%0A  
@@ -688,32 +688,48 @@
 tem.out.println(
+Arrays.toString(
 prob.numberOfLin
@@ -758,83 +758,112 @@
     
+    
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10%7D,
@@ -905,16 +905,17 @@
 vwxyz%22))
+)
 ; // %5B3,
@@ -916,16 +916,17 @@
 // %5B3, 6
+0
 %5D%0A      
@@ -946,16 +946,32 @@
 println(
+Arrays.toString(
 prob.num
@@ -1008,82 +1008,111 @@
     
+  
+  
 4,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10,
+ 
 10%7D,
@@ -1147,16 +1147,17 @@
         
+)
 )); // %5B

Solve problem 806