package leetcode;

/**
 * https://leetcode.com/problems/maximum-number-of-balls-in-a-box/
 */
public class Problem1742 {
    public int countBalls(int lowLimit, int highLimit) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1742 prob = new Problem1742();
        System.out.println(prob.countBalls(1, 10)); // 2
        System.out.println(prob.countBalls(5, 15)); // 2
        System.out.println(prob.countBalls(19, 28)); // 2
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -232,188 +232,318 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        Map%3CInteger, Integer%3E map = new HashMap%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1742 prob = new Problem1742();%0A        System.out.println(prob.countBalls(1
+for (int i = lowLimit; i %3C= highLimit; i++) %7B%0A            int sum = 0;%0A            for (char c : (%22%22 + i + lowLimit).toCharArray()) %7B%0A                sum += c - '0';%0A            %7D%0A            int count = map.getOrDefault(sum
 , 
-1
 0)
-); // 2
+ + 1;
 %0A   
@@ -551,114 +551,111 @@
     
-System.out.println(prob.countBalls(5, 15)); // 2%0A        System.out.println(prob.countBalls(19, 28)); // 2
+    map.put(sum, count);%0A            answer = Math.max(answer, count);%0A        %7D%0A        return answer;
 %0A   

Solve problem 1742