package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/number-of-lines-to-write-string/
 */
public class Problem806 {
    public int[] numberOfLines(int[] widths, String S) {
        int[] result = new int[2];
        result[0] = 1;
        int count = 0;
        for (char c : S.toCharArray()) {
            if (count + widths[c - 'a'] > 100) {
                count = widths[c - 'a'];
                result[0]++;
            } else {
                count += widths[c - 'a'];
            }
        }
        result[1] = count;
        return result;
    }

    public static void main(String[] args) {
        Problem806 prob = new Problem806();
        System.out.println(Arrays.toString(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, 60]
        System.out.println(Arrays.toString(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]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -556,596 +556,7 @@
    %7D
-%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem806 prob = new Problem806();%0A        System.out.println(Arrays.toString(prob.numberOfLines(new int%5B%5D%7B%0A                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,%0A            %22abcdefghijklmnopqrstuvwxyz%22))); // %5B3, 60%5D%0A        System.out.println(Arrays.toString(prob.numberOfLines(new int%5B%5D%7B%0A                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,%0A            %22bbbcccdddaaa%22%0A        ))); // %5B2, 4%5D%0A    %7D
 %0A%7D%0A

Update problem 806