# Amazon Interview Experience for Fresher SDE - 1, Aug 2019

## PROFILE

## Preparation

Don’t create panic in any case in the interview , as even if you are not selected you will learn a lot from your interview experience and perform well in the future. Also I would recommend you Coding Ninjas as according to me it is a good platform to learn basic coding concepts and to practice coding.

## Application Process

Write whatever you are sure about and have actually done that. CGPA plays a good role but not a complete role as it is just eligibility criteria for some companies. Have at least 1 or 2 good projects from which you know everything involved in the project.

## Interview Process

### Round 1

This round consist of two questions and we have to solve both the questions to qualify for the next round.

Count number of occurrences (or frequency) in a sorted array

Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[].

Examples:

Input: arr[] = {1, 1, 2, 2, 2, 2, 3,}, x = 2

Output: 4

2 occurs 4 times in arr[]

Given an array and an integer K, find the maximum for each and every contiguous subarray of size k.

Examples :

Input: arr[] = {1, 2, 3, 1, 4, 5, 2, 3, 6}, K = 3

Output: 3 3 4 5 5 5 6

Explanation:

Maximum of 1, 2, 3 is 3

Maximum of 2, 3, 1 is 3

Maximum of 3, 1, 4 is 4

Maximum of 1, 4, 5 is 5

Maximum of 4, 5, 2 is 5

...

### Round 2

A single coding question was asked that had a lot of corner cases.

Convert a given number into words for news reading by a device.

Example :

If the given input is 62, the output should be 'Sixty two' (without quotes).

### Round 3

It had 3 coding questions followed by basic concepts of DP.

Converting a min heap to a max heap. There can be multiple max heaps possible. Any max heap will be good.

You have been given stock values/prices for N number of days. Every i-th day signifies the price of a stock on that day. Your task is to find the maximum profit which you can make by buying and selling the stocks.

To find the maximum difference between a node and its descendent in the same path in the binary tree.

### Round 4

It had 2 coding questions which were of good level.

Implement a data structure that can perform insertion, deletion, searching in constant time.

Find an MST from a given graph by using Kruskal algorithm.

### Round 5

This was the last round.

You are given a Singly Linked List which contains a series of integers separated by ‘0’.

Between two zeroes, you have to merge all the nodes lying between them into a single node which contains the sum of all the merged nodes. You have to perform this in place.