## Interview Question

Perl Developer Interview

-Beirut

# How do you remove duplicates from an array of integers?

Tags:technical

2

my @input = (1,2,3,1,10,4,3,4,5,2,3,4); my \$seen = {} my @result = grep { not \$seen->{\$_} } @input;

shelling on

0

hi

Anonymous on

0

aliissa

Anonymous on

0

Upon giving a not very efficient answer, the interviewer will ask if you know a more efficient way to solve the problem. You can use any data-strcture so throwing the array in a hash-map will do.

Anonymous on

0

Answer in Java, with example: Integer[] input = new Integer[] {3, 3, 2, 1, 2, 45, 32, 1, 23, 4}; Gingleton g = Gingleton.getInstance(); print(input); Set uniques = new LinkedHashSet(); for(int i=0; i

Manu on

0

use strict; use warnings; my @input = (1,2,3,1,10,4,3,4,5,2,3,4); my \$input = {}; foreach (@input) { if (exists \$input->{\$_}) { \$_ = undef; } else { \$input->{\$_} = undef; } } foreach (@input) { print "\$_ ", if (defined); }

Nazir in perl on

0

Answer in Java, with example: Integer[] input = new Integer[] {3, 3, 2, 1, 2, 45, 32, 1, 23, 4}; Set uniques = new LinkedHashSet(); for(int i=0; i

Manu on