diff options
author | terminaldweller <devi@terminaldweller.com> | 2023-12-07 17:32:28 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2023-12-07 17:32:28 +0000 |
commit | 543adcbdf00f1f3ca5581be2c442f1bcee11e50b (patch) | |
tree | 017212aa202b7fe4c0eb643ec7b6d482cbbcfcde /1903/main.py | |
parent | 1716 (diff) | |
download | leetcode-543adcbdf00f1f3ca5581be2c442f1bcee11e50b.tar.gz leetcode-543adcbdf00f1f3ca5581be2c442f1bcee11e50b.zip |
1903
Diffstat (limited to '1903/main.py')
-rwxr-xr-x | 1903/main.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/1903/main.py b/1903/main.py new file mode 100755 index 0000000..b3d7c03 --- /dev/null +++ b/1903/main.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +class Solution: + def largestOddNumber(self, num: str) -> str: + for i in range(len(num) - 1, -1, -1): + if int(num[i]) % 2 == 1: + return num[:i + 1] + return "" + +def main(): + solution = Solution() + print(solution.largestOddNumber("52")) + print(solution.largestOddNumber("4206")) + print(solution.largestOddNumber("35427")) + +if __name__ == "__main__": + main() |