Amazon Interview Questions – Set 10 (SDE 1)

Amazon chennai this years new and latest off and on campus recruitment procedure.
College: PSIT
Location: Chennai

Hi, Recently I was interviewed for the SDE-I for Amazon, Chennai. Some of the questions here I am sharing based on my memory. They were looking for really cool coders. High expectation on accurate answers. looking for deep understanding of algorithms and data structures. Interviewers were really helpful if you are stuck at some where.

Amazon interview questions:

Q1. Given a n-ary tree. Devise an algo which determines the position at which the 3rd B is present from the given index in constant time complexity.

Q2. Given a dictionary with limited words. Check if the string given to you is a composite of two words which are already present in the dictionary.

Q3. Given a single linked list of certain nodes. Switch adjacent nodes. Eg. 1 2 3 4 will be 2 1 4 3.

Q4. Given a binary search tree. Traverse only the left sub-tree.

Q5. Implementation of AVL tree.

Q6. Given a Integer, find the maximum number that can be formed from the digits.
Input : 8754365
output : 8765543

I told solution in nlogn. He asked me optimize further.

Q7. Write a program to test whether a string and all strings that can be made using the characters of that string are palindrome or not.
Eg:
Input Output
mmo True
yakak True
travel False

Q8. Next, I was asked to design an efficient data structure for two lifts in a building of n floors.

Thank you guys I’m sure this will help you for Amazon company recruitment preparation.

3 Thoughts on “Amazon Interview Questions – Set 10 (SDE 1)

  1. Mohan on June 25, 2015 at 7:18 pm said:

    Where i can get the experience

  2. Tishu Singh on June 26, 2015 at 5:15 pm said:

    Q6. Given a Integer, find the maximum number that can be formed from the digits.
    Input : 8754365
    output : 8765543

    Solution……….

    #include
    #include
    #include
    #include
    void quicksort(char a[],int first,int last);
    void main()
    {
    long i; char a[30];
    scanf(“%ld”,&i);
    sprintf(a,”%ld”,i);
    int j=strlen(a);
    quicksort(a,0,j-1);
    i=atol(a);
    printf(“%ld”,i);
    getch();
    }
    void quicksort(char a[],int first,int last)
    {
    if(first>last)
    {
    return;
    }
    int pivot,i,j,k,temp;
    i=first;
    pivot=a[first];
    j=first;
    for(k=i+1;k<=last;k++)
    {
    if(pivot<a[k])
    {
    j++;
    temp=a[k];
    a[k]=a[j];
    a[j]=temp;
    }
    }
    temp=a[first];
    a[first]=a[j];
    a[j]=temp;
    quicksort(a,first,j-1);
    quicksort(a,j+1,last);
    }

  3. Tishu Singh on June 26, 2015 at 5:22 pm said:

    Q3. Given a single linked list of certain nodes. Switch adjacent nodes. Eg. 1 2 3 4 will be 2 1 4 3.

    Solution ..Here i have also reverse Linklist……….

    #include
    #include
    #include
    #include
    int count=0;
    struct tishu
    {
    int i;
    struct tishu *next;
    }*ptr;
    void rev(struct tishu *temp);
    struct tishu *made(int x);
    void dis();
    void add(int);
    void alternate();
    void main()
    {
    ptr=NULL;
    int x;
    char c;
    do
    {
    printf(“Enter Element\n”);
    scanf(“%d”,&x);
    add(x);
    fflush(stdin);
    printf(“Y/N\n”);
    scanf(“%c”,&c);
    }
    while(tolower(c)!=’n’);
    dis();
    printf(“\n”);
    rev(ptr);
    dis();
    printf(“\n”);
    alternate();
    dis();
    free(ptr);
    getch();
    }
    void alternate()
    {
    struct tishu *temp,*p;
    p=ptr;int k;
    if(count%2==0)
    {
    while(p!=NULL)
    {
    temp=p;
    p=p->next;
    k=temp->i;
    temp->i=p->i;
    p->i=k;
    p=p->next;
    }
    }
    else
    {
    while(p->next!=NULL)
    {
    temp=p;
    p=p->next;
    k=temp->i;
    temp->i=p->i;
    p->i=k;
    p=p->next;
    }
    }
    }

    struct tishu *made(int x)
    {
    count++;
    struct tishu *p=(struct tishu *)malloc(sizeof(struct tishu));
    p->i=x;
    p->next=NULL;
    return p;
    }
    void add(int x)
    {
    if(ptr==NULL)
    {
    ptr=made(x);
    return;
    }
    else
    {
    struct tishu *temp=made(x);
    temp->next=ptr;
    ptr=temp;
    }
    }
    void dis()
    {
    struct tishu *temp=ptr;
    while(temp!=NULL)
    {
    printf(” %d” ,temp->i);
    temp=temp->next;
    }
    }
    void rev(struct tishu *temp)
    {
    if(temp->next==NULL)
    {
    ptr=temp;
    return;
    }
    rev(temp->next);
    struct tishu *p=temp->next;
    p->next=temp;
    temp->next=NULL;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation