FunctionRacerProblemsRace

Largest Odd Number in String

EasyStringsPython, JavaScript, TypeScript, Java, C++

num is a string of digits that represents a big number. Among all the contiguous pieces of num (substrings), return the one with the largest numeric value that is odd, as a string. If no piece is odd, return an empty string.

Example 1

num "52"
returns "5"

Pieces 5, 2, 52: the only odd one is 5.

Example 2

num "4206"
returns ""

No odd digit exists.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems