https://leetcode.com/problems/largest-odd-number-in-string/


Runtime: 7757 ms, faster than 5.07% of Python3 online submissions for Largest Odd Number in String.

Memory Usage: 15.8 MB, less than 7.97% of Python3 online submissions for Largest Odd Number in String.


```python
def isOdd(num):
    num = int(num)
    return num%2 == 1

def greaterThan(num1, num2):
    num1 = int(num1)
    num2 = int(num2)
    return num1 > num2

class Solution:
    def largestOddNumber(self, num: str) -> str:
        #7:05
        if num == "":
            return ""
        
        while len(num) and (not isOdd(num[-1])):
            num = num[:-1]
            
        largest_odd_numbers = []
        for single_char in num:
            best_possible_number = single_char
            for one_possible_number in largest_odd_numbers:
                temp_num = one_possible_number+single_char
                #print(temp_num)
                #if greaterThan(temp_num, one_possible_number):
                best_possible_number = temp_num
            largest_odd_numbers.append(best_possible_number)
            if (len(largest_odd_numbers) > 5):
                largest_odd_numbers.sort(key=len)
                largest_odd_numbers = largest_odd_numbers[len(largest_odd_numbers)//3:]
        #print(largest_odd_numbers)
        largest_odd_numbers = [num for num in largest_odd_numbers if isOdd(num)]
        
        if len(largest_odd_numbers) == 0:
            return ""
        return max(largest_odd_numbers, key=lambda x: int(x))
        #7:19
        #solve performance issue until 8:00
```
