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)        

 

posted @ 2022-05-01 11:07  stronger_el  阅读(69)  评论(0)    收藏  举报