Python code super simple


  • -4
    W

    The python code is super simple but I think I defeated the purpose.

    class Solution:
        # @param num1, a string
        # @param num2, a string
        # @return a string
        def multiply(self, num1, num2):
            return str(long(num1) * long(num2))

  • 1
    I

    Hmmm. That's why people would like to use Python to do ProjectEuler...


  • 0
    E

    accepted using int
    return str(int(num1) * int(num2))


  • -1
    J

    Here is a simple Java version. Take advantage of the BigInteger class.

    public String multiply(String num1, String num2) {
        java.math.BigInteger b1 = new java.math.BigInteger(num1);
        java.math.BigInteger b2 = new java.math.BigInteger(num2);
        return b1.multiply(b2).toString();
    }

  • 3
    M

    Use the utility in the API is recommended in the project. But if you use it in an interview, you will definitely fail .


  • 0
    D

    In a big company, ability to solve tasks by using APIs is necessary.


  • 0
    N

    this is meaningless


  • 0
    Z

    Good luck with that on an interview :D


Log in to reply
 

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