Largest 3-Same-Digit Number

Easy

Description

Given a string num representing a large integer, return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string if no odd integer exists.

Examples

Input:num = "6777133339"
Output:"777"
Explanation:

777 > 333 > 111.

Input:num = "42352338"
Output:""
Explanation:

No three consecutive digits in the string are the same, so no largest good integer exists.

Input:num = "1112224448889"
Output:888
Explanation:

Multiple valid 3-same-digit numbers exist: 111, 222, 444, 888. The answer is 888 as it is the largest.

Constraints

  • 3 ≤ num.length ≤ 1000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!