Solution: Largest Odd Number in String
Explore a greedy algorithm to identify the largest odd integer substring from a numeric string. Learn to scan from the end to quickly find the rightmost odd digit and extract the corresponding substring. Understand the approach's time and space efficiency to solve similar substring problems in coding interviews.
We'll cover the following...
We'll cover the following...
Statement
You are given a string, num, which represents a large integer. Your task is to find the largest odd-valued integer that can be formed as a non-empty substring of num. Return this odd integer as a string. If no odd integer exists, return an empty string ("").
Note: A substring is a continuous sequence of characters within a string.
Constraints:
...