[Java] Two binary search faster than 100%
Intuition
First binary search searching the minimum digits we need.
Second binary search searching the minimum 'b' based on the digitswe got in the first binary
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- First binary search searching the minimum digits we need.
- Second binary search searching the minimum 'b' based on the digitswe got in the first binary search.

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(log(n))$$ for binary sesarch and $$O(n)$$ to construct the output. Overall $$O(n)$$.

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
$$O(1)$$ for binary search and $$O(n)$$ to construct the output. Overall $$O(n)$$.

# Code
```java []
class Solution {
    public String[] splitMessage(String message, int limit) {
        int n = message.length();
        int left = 1;
        int right = getIntLen(n);
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (3 + mid * 2 >= limit) {
                right = mid - 1;
                continue;
            }
            int count = 0;
            for (int i = 1; i <= mid; ++i) {
                count += (limit - (3 + mid + i)) * 9 * (int)Math.pow(10, i - 1);
            }
            if (count < n) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        if (left > right || (3 + left * 2) >= limit) {
            return new String[0];
        }
        int digits = left;
        left = (int)Math.pow(10, digits - 1);
        right = left * 10 - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            int count = 0;
            for (int i = 1; i < digits; ++i) {
                count += (limit - (3 + digits + i)) * 9 * (int)Math.pow(10, i - 1);
            }
            count += (limit - (3 + digits * 2)) * (mid - (int)Math.pow(10, digits - 1) + 1);
            if (count < n) {
                left = mid + 1;
            } else {
                right = mid;
            }
        }
        String[] result = new String[left];
        char[] cArray = message.toCharArray();
        int idx = 0;
        for (int i = 1; i <= left; ++i) {
            StringBuilder sb = new StringBuilder();
            int len = limit - 3 - digits - getIntLen(i);
            while (len > 0 && idx < n) {
                sb.append(cArray[idx]);
                ++idx;
                --len;
            }
            sb.append('<').append(i).append('/').append(left).append('>');
            result[i - 1] = sb.toString();
        }
        return result;
    }

    private int getIntLen(int num) {
        int result = 0;
        while (num > 0) {
            ++result;
            num /= 10;
        }
        return result;
    }
}
```
['Java']