If you allow for the following assumptions: 
1. All numbers fit into a 32 bit or 64 bit integer. 
2. The "arrays" are actually linked lists.

Time complexity: O(N)
Space complexity: O(1)

Solution:
1. Apply radix sort. (binary radix sort would probably do fine)
Note: You can make the sort stable only because of the linked lists (can't 
be done in a simple array). This is the reason for the 2 assumptions.
Complexiy: O(N K). Space: 2 extra pointers = O(1).

2. Find mismatches between the 2 sorted sequences. O(N)

The 2nd assumption "sort-of" cheats because it implicitly requires O(N) 
extra space in the pointers of the linked list.

--
DK

http://twitter.com/divyekapoor
http://www.divye.in

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/vgEeAQHJN08J.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to