You are given a string `num` of digits. An integer is good if it is a substring of `num` of length 3 that consists of one unique digit. Return the maximum good integer as a string, or an empty string `""` if no good integer exists. A substring is a contiguous sequence of characters, and `num` or a good integer may have leading zeros.
You are given a string num of digits. An integer is good if it is a substring of num of length 3 that consists of one unique digit. Return the maximum good integer as a string, or an empty string "" if no good integer exists. A substring is a contiguous sequence of characters, and num or a good integer may have leading zeros.
Example 1:
Input: {"num":"6777133339"}
Output: 777
Constraints:
3 <= num.length <= 1000
num only consists of digits.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"num":"6777133339"}
best starts empty. Slide a window of 3 digits across num (8 positions) and keep the largest window whose digits are all equal.