Amazon Software Development Engineer Challenge

Amazon SDE Coding Challenge 2022

AMAZON is looking to hire Software Development Engineers who are willing to build products used every single day by their friends and family? If you are passionate about building products that impact millions of consumers this is the perfect hiring for you. You will be entrusted with a high degree of ownership and encouraged to take risks, experiment and learn quickly

AMAZON SDE Coding Challenge

More About the SDE Challenge

Software Development Engineers (SDEs) are the drivers of Amazon’s many tech innovations that are collectively transforming the way our customers live their lives and run their businesses. You will have an opportunity to work on the latest technology to design and implement new services and applications.

 

Important Dates

Opens at April 22, 6:00 PM IST
Closes atMay 2, 11:55 PM IST
Duration3 hrs

Challenge Format: 2 programming questions to be solved in 3 hours

Eligibility Criteria: 

  • Graduates with strong Computer Science fundamentals with 1+ years experience in software development.
  • Willing to relocate to Bangalore, Delhi, & Hyderabad for the job

Open Positions :

  • SDE 1
  • SDE 2

 

Amazon SDE ChallengeDetails
Experience1 Year+
CompensationBest in Industry
Job LocationBangalore, Delhi & Hyderabad

 

Required Educational Background :

  • The candidates should compulsory be from BE/B.Tech, ME/M.Tech, MCA  background for applying in SDE2 roles at Amazon.
  • Candidates from Integrated 5 years MSc course can also apply.
  • Candidates from Computer Science and Information Science background with strong basics are required for SDE roles however they will be considered candidates from other branches if they have relevant work experience in Software Development field.

 

Prerequisites skills :

  •  Design Experience: Ideal candidate to have min 1+ years of experience in designing software, HLD – 6 months + and LLD – 1+ years, Check on HLD exp based or org.
  • It’s ideal to have candidates worked on highly scalable and distributed systems.
  • SDLC lifecycle – Complete understanding on end to end Software Development Lifecycle model from Requirements gathering, Feasibility Analysis, Design , Development until Deployment
  • Good to have candidates who have developed modules or features of the products from scratch, good to have candidates who redesigned and reworked the existing product.
  • Good to have candidates worked on complex problems and been part of the projects from scratch, need not be at a very high scale.
  • Ideal candidates would have experience in projects related to Microservice architecture, Distributed systems.

Practice Coding Questions

Question 1 – Minimum streets lights

Problem Statement -: Street Lights are installed at every position along a 1-D road of length n. Locations[] (an array) represents the coverage limit of these lights. The ith light has a coverage limit of locations[i] that can range from the position max((i – locations[i]), 1) to min((i + locations[i]), n ) (Closed intervals). Initially all the lights are switched off. Find the minimum number of fountains that must be switched on to cover the road.

Example

n = 3

locations[] = {0, 2, 13}then

For position 1: locations[1] = 0, max((1 – 0),

1) to mini (1+0), 3) gives range = 1 to 1

For position 2: locations[2] = 2, max((2-2),

1) to min( (2+2), 3) gives range = 1 to 3

For position 3: locations[3] = 1, max( (3-1),

1) to min( (3+1), 3) gives range = 2 to 3

For the entire length of this road to be covered, only the light at position 2 needs to be activated.

Returns:

int : the minimum number of street lights that must be activated

Constraints :

  • 1<_n<_ 10^5
  •  O<_locations[i] <_ mini (n,100) (where 1 <_1<_10^5)

Sample Input For Custom Testing :

3 ->locations[] size n = 3

1 ->locations[] [1, 1, 1]

1 ->Sample Output

Sample Output :

1

Run
#include <stdio.h>
int
main ()
{
  int i, j, n;
  scanf ("%d" , &n);
  for (i = 0; i < n; i++)
    {
      for (j = 0; j < n; j++)
	{
	  if (j < n - i - 1)
	    printf ("*");
	  else
	    printf (".");
	}
      for (j = 0; j < n - 1; j++)
	{
	  if (j < i)
	    printf (".");
	  else
	    printf ("*");
	}
      printf ("\n");
    }

  for (i = 2; i <= n; i++)
    {
      for (j = 0; j < n; j++)

	{
	  if (j < i - 1)
	    printf ("*");
	  else
	    printf (".");

	}
      for (j = 0; j < n - 1; j++)
	{
	  if (j < n - i)
	    printf (".");
	  else
	    printf ("*");
	}
      printf ("\n");
    }
  return 0;
}
Run
import java.util.*;
class Main
{
  public static void main(String[] args)
{
  Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
 int i,j;
   for(i=0;i< n;i++)
    {
        for(j=0;j< n;j++)
        {
            if(j< n-i-1)
                System.out.print("*");
            else
               System.out.print(".");
        }
        for(j=0;j< n-1;j++)
        {
            if(j< i)
                System.out.print(".");
            else
                System.out.print("*");
        }
      System.out.println();   
    }

 for(i=2;i<=n;i++)
    {
     for(j=0;j< n;j++)

        {
            if(j< i-1)
                System.out.print("*");
            else
                System.out.print(".");

        }
      for(j=0;j< n-1;j++)
            {
                if(j< n-i)
                   System.out.print(".");
                else
                    System.out.print("*");
            }
            System.out.println();
     }
 }
}
Run
n = int (input ()) 
for i in range (n):
    print ("*"*(n - 1 - i) + "."*(2 * i + 1) + "*"*(n - 1 - i))
    for i in range (n - 1):
        print ("*"*(i + 1) + "." *(2 * (n - 2 - i) + 1) +"*"*(i + 1))

Question 2 – Disk Space Analysis

Problem Statement -:  You are given an array, You have to choose a contiguous subarray of length ‘k’, and find the minimum of that segment, return the maximum of those minimums.

Sample input 0 

1 →  Length of segment x =1

5 →  size of space n = 5

1 → space = [ 1,2,3,1,2]

Sample output

3

Explanation

The subarrays of size x = 1 are [1],[2],[3],[1], and [2],Because each subarray only contains 1 element, each value is minimal with respect to the subarray it is in. The maximum of these values is 3. Therefore, the answer is 3

Run
#include <bits/stdc++.h>
using namespace std;
vector < int >arr;
int prevmin = -1;
int flag = 0;
int x, n, q;

int sorting (int start, int end)
{
  if (start + 1 == n)
    {
      start = 0;
      end = end - n;
    }
  if (start == end)
    return arr[start];
  return min (arr[start], sorting (start + 1, end));
}

int func (int start, int end)
{
  if (flag == 0)
    {
      flag++;
      return prevmin = sorting (start, end);
    }
  if (arr[start - 1] == prevmin)
    return prevmin;
  return prevmin = (arr[end] <= prevmin) ? prevmin : sorting (start, end);

}

int main ()
{
  cin >> x >> n;
  int ans = 0;
  for (int i = 0; i < n; i++)
    {
      cin >> q;
      arr.push_back (q);
    }
  for (int i = 0; i < n; i++)
    {
      ans = max (ans, func (i, i + x - 1));
    }
  cout << ans;
}

Run
import java.util.*;
class Main
{
  public static void main (String[]args)
  {
    Scanner sc = new Scanner (System.in);
    int x = sc.nextInt ();
    int n = sc.nextInt ();
    int arr[] = new int[n];
    for (int i = 0; i < n; i++)
        arr[i] = sc.nextInt ();

    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;

    for (int i = 0; i <= n - x; i++)
      {
	min = Integer.MAX_VALUE;
	for (int j = i; j < (i + x); j++)
	  min = Math.min (min, arr[j]);
	max = Math.max (min, max);
      }
    System.out.println (max);
  }
}

Run
s=int(input())
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
   

def min_in_segment(start,end,prev,s,prev_min):
    if s==1:
        return a[start]
    else:
        if prev==-1 or prev_min==-2:
            return min(a[start:end+1])
        elif prev_min!=-2:
            if prev!=prev_min:
                if a[end] < prev_min:
                    return a[end]
                else:
                    return prev_min
            else:
                return min(a[start:end+1])
            
msf=-1
prev=-1
prev_min=-2
for i in range(n-s+1):
    new_min=min_in_segment(i,i+s-1,prev,s,prev_min)
    msf=max(msf,new_min)
    prev=a[i]
    prev_min=new_min
print(msf)