You are given a numeric string s where every character is a digit from 1 to 9, and an integer k.
Your task is to divide s into multiple contiguous substrings such that:
Every character is used exactly once.
When each substring is converted to an integer, its value does not exceed k.
Among all valid ways to divide the string, return the smallest number of substrings required.
If it is impossible to divide the string under these rules, return -1.
Input: s = "314159", k = 70
Output: 3
Explanation:
Possible partition: "31", "41", "59" All values ≤ 70, total substrings = 3.
Input: s = "9999", k = 900
Output: 2
Explanation:
Any substring with more than 1 digit exceeds 900, but single-digit values 9 still exceed k → no valid partition.
Accepted:
Submission: