Are we allowed this type of a Python solution?


  • 0
    N

    Are we allowed this type of a solution for Python, or would we not be allowed to do something like this on the interview?

    class Solution(object):
        def plusOne(self, digits):
            """
            :type digits: List[int]
            :rtype: List[int]
            """
            number = map(str, digits)
            number = "".join(number)
            number = list(str(int(number) + 1))
            new_num = []
            for num in number:
                new_num.append(int(num))
            
            return new_num

  • -1
    D

    The problem is, if the number is larger than the limit for "int" type, this won't work.


Log in to reply
 

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