Problem
Ask
Submissions

Problem: Largest Odd Number in String

Medium
30 min
Explore techniques to identify the largest odd integer substring within a numeric string using greedy strategies. This lesson helps you understand substring properties and implement efficient solutions to optimize for coding interviews.

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:

  • 11 \leq num.length 104\leq 10^4

  • num only consists of digits and does not contain any leading zeros.

Problem
Ask
Submissions

Problem: Largest Odd Number in String

Medium
30 min
Explore techniques to identify the largest odd integer substring within a numeric string using greedy strategies. This lesson helps you understand substring properties and implement efficient solutions to optimize for coding interviews.

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:

  • 11 \leq num.length 104\leq 10^4

  • num only consists of digits and does not contain any leading zeros.