lc周赛490-6047. 移除指定数字得到的最大结果
class Solution: def removeDigit(self, number: str, digit: str) -> str: max_result = 0 for i in range(0, len(number)): if number[i] == digit: if i == 0: max_result = max(int(number[i + 1:]), max_result) elif i == len(number)-1: max_result = max(int(number[0:i]), max_result) else: max_result = max(int(number[0:i] + number[i + 1:]), max_result) return str(max_result)
浙公网安备 33010602011771号