One Liner Solution in Python


#1

class Solution:
# @param A : list of integers
# @param B : list of integers
def merge(self, A, B):
A[:]=sorted(A+B)
#A[:]=[str(i) for i in A]


#2

Very nice…
Unfortunately that’s might not be convincing enough for interviewers who will be expecting a more clever solution.


#4

@rashi174 The Question clearly says solve in O(n+m) and sorting is O(nlogn). Try something clever using 2 pointers.


#5

very nice, is python backend implement sorted by quick sort?
otherwise this solution is o(nlogn)
while the prior make it easy to solve in o(n)


#6

What is the difference between

A[:]=sorted(A+B)
and
A=sorted(A+B)