Educative

Merge Two lists - needs clarification

This question needs clarification. I just used sorted(lst1 + lst2) instead of the multiple lines in the solution. I did not realise you can’t use sorted function

1 Like

Same. I wrote the same solution as you. I just used the most ‘pythonic’ library functions, as I would in a real life code problem.

Hi Daugavpils,

According to the problem, we should prefer solving the problem by not using any built-in functions.

For our practice, we should prefer writing our own code.

Usually, to prepare for coding interviews, we should prepare ourselves for each situation.

However, I used the following code, which works fine for me, and passed all test cases.

def merge_lists(lst1, lst2):
    
    return sorted(lst1 + lst2)

I hope this answered your question.

Thank you!

1 Like

I wrote the same. I guess it makes sense to not use the in-built functions just for the sake of learning how things really happen at the back end.