Akamai Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

step 1: sort the array //O(n.log(n))

arr=2,5,3,1,8,7,5,4  -->  1,2,3,4,5,5,7,8

//size=8

step 2:
i=0, j=7
if a[i]+a[j]==K //done
if a[i]+a[j] > K //j--
if a[i]+a[j] < K //i++

repeat step2, till it reaches mid point //O(n)

- shoonya.mohit May 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

awesome doode!

- Anonymous May 06, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

too good

- Anonymous September 07, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Good...

- Benazir November 27, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

This makes not just two good but 4 good!

- anon February 25, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

lol at above comments ... this is the standard quicksort algorithm!

- aa August 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

lol at above comments ... this is the standard quicksort algorithm!

- aa August 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice

- 003 (:))* September 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

nice solution as complexity considered .thumbs up

- anon July 28, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

In addition to the abv method, one can also use the hash table method if space is not a constrain.
Save all the elements in a hash table. For each value store a self bit so as to make sure 'sum - element ! = element itself'.
Chaining could be used for similar elements.
For each element search
Change self = 1
if('sum - element' is present in hash table && self ! = 1)
{print the two numbers.
return}
else {self = 0}

- Anonymous May 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

If you use more space to make time less, it is reasonable. Otherwise, it is just a inferior method.

- chenming831 May 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

use hash . -> O(n) in amortized

- dbguy May 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

the detailed solutions are here geeksforgeeks.org/?p=484

- Gaurav May 03, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

thnx 4 the link,it explains very well

- newbie June 04, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

You can use merge sort to solve this question.
Steps are:
1- Sort the given array element using merge sort .
2- declare new array and subtract the given array elements from k and store in new array.
3- Sort the second array. remove the dulicate values from arrai and array2.
4- and then apply merge sort on array1 and array2 and save it to new array.
5- nw the elements that are repeated twice in an array3 are the numbers whose sum is k.

Complexity is O(nlgn)

- vivek May 23, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think this is the best algorithm....

1.Sort ascendancy, remove duplicates also in the process
2.Remove numbers which are >= k
3.Do steps 4 through 8 till i != j
4.Start with i = 0
5.Start with j = size - 1
6.If the sum is == k, display a[i]+a[j] = k, i++, j--
7.If the sum is < k, i++, go to step 5
8.If the sum is > k, j--, go to step 5

Can somebody calculate the complexity for this please? I don't know how to do...

- nagabhushana.s June 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sorry...shoonya mohit has already done that. great job, man!

- nagabhushana.s June 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

use hashing.
a[]={2 5 3 1 8 7 5 4}; and k=6;
Hashyable ht= new Hashtable;

for(i=0;i<n;i++)
b=k-a[i];
if(ht.contains(b))
printf(" the two elements are %d and %d",b,a[i]);
else
ht.add(a[i]);

- motu August 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

TC: O(n)

- motu August 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sort + binary search should work.

- Anonymous January 29, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More