How would I remove 6s instead of 9s


  • 0
    L

    This code changes the base to 9 and hence removes all 9s.

    How do I change it so that it removes 6s instead of 9s ?

        def newInteger(self, n):
            a = []
            while n > 0:
                a.append(n % 9)
                n /= 9
            r = 0
            for x in a[::-1]:
                r = r * 10 + x
            return r
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.