DEV Community

Discussion on: 🎯Merge two sorted arrays without using any extra space🎯

Collapse
 
aizuliswafaza profile image
aizuliswafaza

I prefer to turn the array into a list then use the .AddList function to cmerge the second lists then call the .sort function for sorting.

how about that? maybe this method is not very good either.

Collapse
 
kaiwalyakoparkar profile image
Kaiwalya Koparkar

Yeah, you are right but I don't think the interviewer will like you using inbuilt library functions.🙄

Collapse
 
trueneu profile image
Pavel Gurkov • Edited

Kaiwalya, that didn't stop you from using the built-in sort, right?

aizuliswafaza, the problem is different here: the moment you convert this array into a list, you break the constraint on using constant additional memory.

Thread Thread
 
kaiwalyakoparkar profile image
Kaiwalya Koparkar

That's true