Amazon Interview Question for Software Engineer / Developers






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

1> p= XOR 1 to n

for i=1 to n-1
p=p XOR a(i)

p is the ans .

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2 > p= XOR 1 to N-1

for i=1 to N
p= p XOR a(i)

p is the ans .

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

3 >

p=0;
for i=1 to N
p=p XOR a(i)

p= ans .

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

4 >
bool CheckBST ( node* T , int min , int max )
{
if ( (T-> data < min ) || (T-> data >= max ) )
return false;

bool p=true,q=true;

if( T-> left !=NULL )
p=CheckBST ( T->left , min, T->data) ;

if( T-> right !=NULL )
q=CheckBST ( T->right , T->data , max ) ;

return p&q ;

}

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Wrong answer, it checks only one one level but not the previous parent.

- Wrong January 15, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

6 > ATOI()

int atoi( char* str )
{
if( str==NULL )return 0;
int res=0;
bool neg=false;
int i=0;

if( str[0]=='-' )
{
neg=true;
i=1;
}

for( ;str[i]!='\0' ;i++)
res = res*10+ (str[i]-'0');

if( neg )
res=-res ;


return res;

}

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool WildCardMatch ( char* pat , char* text )
{

while ( *text )
{

switch ( * pat )
{
case '?' :
if( *text=='.' )return false;
break;


case '*' :
{
while( * pat== '*' )pat++;

if( !*pat )return true ;

while ( *text )
if( WildCardMatch( pat,text++) )return true ;

return false;

}

default :
if( *pat != *text )return false ;


}

pat++;
text++;

}

while( *pat=='*' )
pat++;

return !(*pat) ;

}

- 7 > February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1> Implement the Dictionary using TST .

2> Using BFS we can determine the shortest path between one word to another if we consider all words to be nodes .

- Word Game February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

why do you need shortest path. You need 4 steps to get 4 meaningful words.

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

12 > Thrashing !

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

15 >

void Delnode( node* ptr )
{
if( ptr==NULL )return ;

if( ptr->next==NULL ) return ; /* We cannot do anything :-( */

node* t=ptr->next;

copy( ptr,t ); /* Copy data of t into ptr */

ptr->next=t->next;

t->next=NULL;

free(t);

}

- JD February 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The question is pointer is given to the node to be deleted and you assumed the pointer is given to the previous of node to be deleted and then uyou are just copying the data of next to next node.

This is not the answer.

- Abhishek February 03, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

15>

void DelNode(node **head, node *del_ptr)
{
   node *temp;
   if (*head == NULL || del_ptr == NULL) return;
   if (*head->next == del_ptr) {
       *head->next = del_ptr->next;
       free(del_ptr);
   }
   temp = *head;
   while(temp->next) {
      if (temp->next == del_ptr) {
         temp->next = del_ptr->next;
         free(del_ptr);
          return;
      }
      temp = temp->next;
   }  
}

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

with no silly bugs ;)

void DelNode(node **head, node *del_ptr)
{
   node *temp;
   if (*head == NULL || del_ptr == NULL) return;
   if (*head == del_ptr) {
       *head = del_ptr->next;
       free(del_ptr);
       return;
   }
   temp = *head;
   while(temp->next) {
      if (temp->next == del_ptr) {
         temp->next = del_ptr->next;
         free(del_ptr);
          return;
      }
      temp = temp->next;
   }  
}

- neo March 13, 2010 | Flag


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