Tuesday, March 25, 2014

Interview experience for perl developer with booking.com

Recently I had an opportunity to give the interview for booking.com for perl developer.

I got the call from the HR after 2 week from the CV submission date. Initial HR round was very simple . Introduction about the company and kind of work you are expected to do, the team strength etc

The online interview with the technical people was arrange after 2 people with 2 perl developer. The interview was about perl.



The question were as follows; I have created the gist for the question on github.


=head Question1
You have the file with word at a single line.
#input sample file
abactor
abaculus
abacus
Abadite
.
.
Zyrenian
#Output
******************************************************************a
*************b
**********************************c
**********************d
*******************************************************************************e
a) you have to count the character and create a histogram in alphabetical order.
b) now you have to produce a histogram with max 80 character in line in reference to max count
c) now same out based histrogram based on the character count
=cut
#!/usr/bin/perl
use warnings;
use strict;
my %wordCount = ();
my $normalfac = 0;
open(my $fh,"$ARGV[0]") or die "cnot open file : $!\n";
while (<$fh>) {
chomp;
foreach (split("",$_)) {
my $char = $_;
if (exists $wordCount{$char}) {
$wordCount{$char}++ if ($char=~/[a-z]/i);
}
else {
$wordCount{$char} = 1;
}
if (exists $wordCount{$char} &&
$normalfac < $wordCount{$char}
) {
$normalfac = $wordCount{$char};
}
}
}
local $\ = "\n";
#a
foreach (sort {$a cmp $b} keys %wordCount) {
print "*" x int(($wordCount{$_}*80)/$normalfac),"$_";
};
#b
foreach (sort {$wordCount{$b} <=> $wordCount{$a}} keys %wordCount) {
print "*" x int(($wordCount{$_}*80)/$normalfac),"$_";
};
=head Question2
You have datastructure
my $users = [
{
name => 'John',
score => 10,
},
{
name => 'Bob',
score => 1,
},
{
name => 'Carlos',
score => 5
},
{
name => 'Alice',
score => 5,
},
{
name => 'Donald',
score => 7
}
];
now u have to arrange the name with highest to lower score,
if score is same than in alphabetical order
#expected output:
# John
# Donald
# Alice
# Carlos
# Bob
=cut
my %hash=();
foreach (@$users) {
$hash{$_->{name}} = $_->{score};
}
foreach (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
print "$_\n";
};
#
=head Question3
you have an array @names = qw(John Donald Alice Carlos Bob)
you have ton find out the length using map funtion?
now you have to filter name with less than 4
=cut
view raw booking.pl hosted with ❤ by GitHub

Though I was able solved all the question put by them , but took few hints from the interviewer, which seems to the reason to be not selected for the amsterdam trip.
Do leave your comment , if you find with the post useful. 

No comments:

Post a Comment