My code is:
def merge(self, A, m, B, n): i=0 j=0 A=A+B while i<m: if j>-n: while A[m-j]<A[m-j-1] and m-j-1>=0: t=A[m-j] A[m-j]=A[m-j-1] A[m-j-1]=t j=j+1 i=i+1 j=-i
Input: [ ],
I believe this line
A=A+B should be instead of
m=m+n, or something like that.
m indicates the original length of A,
n indicates length of B, also as problem describes that
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B.