2259. Remove Digit From Number to Maximize Result

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 2259

class Solution:
    def removeDigit(self, number: str, digit: str) -> str:
        last = -1
        n = len(number)
        for i, d in enumerate(number):
            if d == digit:
                last = i
                if i + 1 < n and d < number[i + 1]:
                    break
        return number[:last] + number[last + 1 :]