Could you help me with my Python code? What's wrong?

  • 0

    I have tried on python interpreter that I could get the right answer, however, the leetcode didn't recognize my code.

    class Solution(object):
        def merge(self, nums1, m, nums2, n):
            nums1 = nums1[0:m] + nums2[0:n]
            i = 1
            while i < m+n:
                if nums1[i] < nums1[i-1] and i >= 1:
                    temp = nums1[i-1]
                    nums1[i-1] = nums1[i]
                    nums1[i] = temp
                    i = i - 2
                i = i + 1

Log in to reply

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