Is there any thing wrong with the Python code judgement?


  • 0
    G

    My output is always [0], even if my function return [1].

    For example:

    class Solution:
    # @param A a list of integers
    # @param m an integer, length of A
    # @param B a list of integers
    # @param n an integer, length of B
    # @return nothing
    def merge(self, A, m, B, n):
    return [1]


  • 0
    M

    With this problem, there is no return.

    @return nothing
    

    What you need to do is put the sorted array into A, which already has enough room for all the elements in A and B together.

    The reason it is saying your output is [0] is because that is the contents of array A at the end of your method. A=[], with n 0s added to the end to provide space for B, resulting in []+[0] = [0]. As it believes there is no return, it looks at A when the function ends and compares it to the expected value.


Log in to reply
 

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