Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: •SPOILERS Re: (OT) Interview questions -- your response?

by ichimunki (Priest)
on Sep 03, 2002 at 19:16 UTC ( #194867=note: print w/ replies, xml ) Need Help??


in reply to •SPOILERS Re: (OT) Interview questions -- your response?
in thread (OT) Interview questions -- your response?

So how about solving the array union question without hashes? I'd sort the arrays and use something like:

while( @sort_a and @sort_b ){ if( $sort_a[0] < $sort_b[0]){ shift(@sort_a); } elsif( $sort_a[0] > $sort_b[0]{ shift(@sort_b); } else{ push @new_array, $sort_a[0]; shift(@sort_a); shift(@sort_b); } }
This will handle duplicate entries in the arrays differently than the hash solution.


Comment on Re: &bull;SPOILERS Re: (OT) Interview questions -- your response?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://194867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2015-07-05 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls