Pergunta de entrevista da empresa Walmart

You have 2 not sorted integer Lists. Write a code to merge them with unique integers in sorted order. For example 1, 4, 3 and 2, 4, 5 result will be 1, 2, 3, 4, 5

Respostas da entrevista

Sigiloso

10 de ago. de 2016

Another solution possible: if range of number is known, then simple bucket sort approach can work (or bit buckets where each bit represent 1 number), just init bucket-table and then start pushing both list on the bucket o(1). Cons: in the end - walk of bucket-table to detect which entry in bucket is valid (i.e. number in either input list).

1

Sigiloso

8 de ago. de 2016

I first sorted them, (since we have integers, we can do Radix sort and sort these numbers in O(n) complexity). and then usual List merge. Take the i-th and j-th characters, and compare them. there are three if else cases.

1