bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 1903. Largest Odd Number in String

1903. Largest Odd Number in String

Leetcode Solutions

Find the Rightmost Odd Digit

  1. Iterate over the characters of num from right to left.
  2. For each character, check if it is an odd digit by casting it to an integer and taking its value mod 2.
  3. If an odd digit is found, return the substring of num starting at index 0 and ending with the index of the found odd digit.
  4. If no odd digit is found by the end of the iteration, return an empty string.
UML Thumbnail

Brute Force Search for Largest Odd Substring

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...