Does it make sense for such a python solution


  • 0
    P
    class Solution:
        # @param num1, a string
        # @param num2, a string
        # @return a string
        def multiply(self, num1, num2):
            return str(int(num1)*int(num2)) if num1 and num2 else ''
    

    it passes the OJ but I did not see the point of this problem. Anybody help?


  • 2
    S

    Python handles a lot of difficulties for you, but you are supposed to identify these problems as a software engineer candidate, and explicit state what you would do to them without the ease provided by Python. If I were the interviewer, I'd probably ask you to implement 'int' and 'str' yourself if you give me an answer like that. Plus, I'd follow up with a question such as 'What if you were to work with a language where num1 and num2 exceed the upper range of integer representation?'

    Hint: try to solve the problem without int/str conversion.


Log in to reply
 

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