Amazon Interview Question for Software Engineer / Developers






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

Another example: it takes aabbcccddddbbbb and returns a2b2c3d4b4.

- Anonymous March 05, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this is easy using map since it is sorted with map

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

Can you explain please ?

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

We're not trying to find a histogram, so no.

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

{void count_item(int a[],int len){
int item, item_count, present_idx;
int i;
i = 0;
present_idx = 0;
item_count = 1;
item = a[i];
for (i=1; i<len; i++) {
if (item ==a[i]) {
item_count++;
}
else {
a[present_idx++] = item;
a[present_idx++] = item_count;
item_count = 1;
item = a[i];
}
}
a[present_idx++] = item;
a[present_idx++] = item_count;
a[present_idx]=0;
for (i=0; i<present_idx; i++) {
if(a[i]==0)
break;
printf("%d ",a[i]);
}
}
}

- A March 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{void count_item(int a[],int len){
int item, item_count, present_idx;
int i;
i = 0;
present_idx = 0;
item_count = 1;
item = a[i];
for (i=1; i<len; i++) {
if (item ==a[i]) {
item_count++;
}
else {
a[present_idx++] = item;
a[present_idx++] = item_count;
item_count = 1;
item = a[i];
}
}
a[present_idx++] = item;
a[present_idx++] = item_count;
a[present_idx]=0;
for (i=0; i<present_idx; i++) {
if(a[i]==0)
break;
printf("%d ",a[i]);
}
}
}

- A March 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Problem:
================
given a stream of integers.. 112233344442222 write a function that would return as 1222334424
it takes aabbcccddddbbbb and returns a2b2c3d4b4.

Example:
================
A[aabbcccddddbbbb]

Result: a2b2c3d4b4

ALGO:
================
Take A[i] compare with all and increase the counter
put Str S += A[i] + Counter
Return the complete String

CODE:
================



private string CharCount(Array A[], Int n) \\N IS THE SIZE OF ARRAY
{
FOR(I=0;I<N;I++)
{
FOR(J=0;J<N;J++)
{
IF(a[I]==a[J])
{
COUNT++;
}
ELSE
{
J=N; \\TO KILL THE ITERATIONS
}
}
STRING S += A[I]+COUNT;
}
RETURN s;

}



ORDER:
================
O(N^2)

- tarun phaugat March 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Its Sudo Code:
*************
PreDigit=GetDigit();
Count=1;
while(IsMoreDigit())
{
Digit=GetDigit();
if(PreDigit==Digit) Count++;
else
{
cout<<PreDigit<<Count;
PreDigit=Digit;
Count=1;
}
}
cout<<PreDigit<<Count;

- Smily March 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

guys... this is RLE (Run Length encoding) Used for compression in fax type of images..... can easily be done in O(n)

- Anonymous March 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

guys... this is RLE (Run Length encoding) Used for compression in fax type of images..... can easily be done in O(n)

- arnab March 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
private static void getCharsCount(String s){
String result = "";
int count = 1;

for(int i = 0; i < s.length(); ++i){
if(i == s.length()-1 || s.charAt(i) != s.charAt(i+1)){
result += "" + s.charAt(i)+count;
count = 1;
}else{
count++;
}
}

System.out.println(result);
}
}

O(n)

- vaibhav.iit2002 March 25, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what would happen when a digit exceeds more than 10 times for example , if 1 runs for 12 times then we represent it as 112 , how can we decode it ?Is there a limit on number of times a character can occur ?

- k.krishnakarthik July 22, 2010 | 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