Amazon interview experience Real time questions & tips from candidates to crack your interview

Devops Engineer

Amazon
upvote
share-icon
4 rounds | 7 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: DBMS, Data Structures and Algorithms , OOPS, Maths puzzles, Aptitude, Computer Network and Operating System
Tip
Tip

Tip 1 : Must do Previously asked Interviews Questions.
Tip 2 : Prepare OS, DBMS, OOPs, Computer Networks well.
Tip 3 : Prepare well for one project mentioned in the resume, the interviewer may ask any question related to the project, especially about the networking part of the project.

Application process
Where: Linkedin
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at least 2 good projects mentioned in your resume with a link
Tip 2 : Focus on skills, internships, projects, and experiences.
Tip 3 : Make it simple, crisp, and one page
Tip 4 : Only write those skills in which you are good.

Interview rounds

01
Round
Hard
Online Coding Test
Duration75 minutes
Interview date13 May 2022
Coding problem2

It was online coding assessment round on the hackerrank platform. It consists of two coding questions of hard and medium level.

1. Wildcard Pattern Matching

Hard
50m average time
30% success
0/120
Asked in companies
SalesforceFreshworksWalmart

Given a text and a wildcard pattern of size N and M respectively, implement a wildcard pattern matching algorithm that finds if the wildcard pattern is matched with the text. The matching should cover the entire text not partial text.

The wildcard pattern can include the characters ‘?’ and ‘*’

 ‘?’ – matches any single character 
 ‘*’ – Matches any sequence of characters(sequence can be of length 0 or more)
Problem approach

This Solution use 2D DP. beat 90% solutions, very simple.

Here are some conditions to figure out, then the logic can be very straightforward.

1, If p.charAt(j) == s.charAt(i) : dp[i][j] = dp[i-1][j-1];
2, If p.charAt(j) == '.' : dp[i][j] = dp[i-1][j-1];
3, If p.charAt(j) == '*': 
here are two sub conditions:
1 if p.charAt(j-1) != s.charAt(i) : dp[i][j] = dp[i][j-2] //in this case, a* only counts as empty
2 if p.charAt(i-1) == s.charAt(i) or p.charAt(i-1) == '.':
dp[i][j] = dp[i-1][j] //in this case, a* counts as multiple a 
or dp[i][j] = dp[i][j-1] // in this case, a* counts as single a
or dp[i][j] = dp[i][j-2] // in this case, a* counts as empty
Here is the solution

public boolean isMatch(String s, String p) {

if (s == null || p == null) {
return false;
}
boolean[][] dp = new boolean[s.length()+1][p.length()+1];
dp[0][0] = true;
for (int i = 0; i < p.length(); i++) {
if (p.charAt(i) == '*' && dp[0][i-1]) {
dp[0][i+1] = true;
}
}
for (int i = 0 ; i < s.length(); i++) {
for (int j = 0; j < p.length(); j++) {
if (p.charAt(j) == '.') {
dp[i+1][j+1] = dp[i][j];
}
if (p.charAt(j) == s.charAt(i)) {
dp[i+1][j+1] = dp[i][j];
}
if (p.charAt(j) == '*') {
if (p.charAt(j-1) != s.charAt(i) && p.charAt(j-1) != '.') {
dp[i+1][j+1] = dp[i+1][j-1];
} else {
dp[i+1][j+1] = (dp[i+1][j] || dp[i][j+1] || dp[i+1][j-1]);
}
}
}
}
return dp[s.length()][p.length()];
}

Try solving now

2. Scramble String

Hard
15m average time
85% success
0/120
Asked in companies
Rubrik, Inc.Info Edge India (Naukri.com)Postman

You are given an integer ‘N’ and two strings ‘S’ and 'R' each having size = ‘N’. You can scramble the string ‘S’ to obtain string 'R' using the following operations:

1. If the length of the string is greater than 1:

  • Select any random index and split the string into two non-empty substrings. For e.g: if the string is ‘S’, then divide it into two non-empty substrings ‘A’ and ‘B’ such that ‘S’ = ‘A’ + ‘B’.
  • You can choose to swap the two substrings or keep them in the same order, i.e., after this operation string ‘S’ may become either ‘S’ = ‘A’ + ‘B’ or ‘S’ = ‘B’ + ‘A’.
  • Apply the first step recursively on each of the two strings ‘A’ and ‘B’.
  • 2. If the length of the string is equal to 1 then stop.

    Your task is to return true if 'R' is a scrambled string of ‘S’ else return false.

    Note:

    1. Both the strings are non-empty and are of the same length.
    
    2. You can apply the above operations any number of times on ‘S’.
    
    3. The operations can only be applied on the string ‘S’.
    
    4. ‘S’ and 'R' consist of lowercase letters only.
    
    Problem approach

    class Solution {
    public:
    //for storing already solved problems
    unordered_map mp;


    bool isScramble(string s1, string s2) {
    //base cases

    int n = s1.size();

    //if both string are not equal in size
    if(s2.size()!=n)
    return false;

    //if both string are equal
    if(s1==s2)
    return true; 



    //if code is reached to this condition then following this are sure:
    //1. size of both string is equal
    //2. string are not equal
    //so size is equal (where size==1) and they are not equal then obviously false
    //example 'a' and 'b' size is equal ,string are not equal
    if(n==1)
    return false;

    string key = s1+" "+s2;

    //check if this problem has already been solved
    if(mp.find(key)!=mp.end())
    return mp[key];

    //for every iteration it can two condition 
    //1.we should proceed without swapping
    //2.we should swap before looking next
    for(int i=1;i {

    //ex of without swap: gr|eat and rg|eat
    bool withoutswap = (
    //left part of first and second string
    isScramble(s1.substr(0,i),s2.substr(0,i)) 

    &&

    //right part of first and second string;
    isScramble(s1.substr(i),s2.substr(i))
    );



    //if without swap give us right answer then we do not need 
    //to call the recursion withswap
    if(withoutswap)
    return true;

    //ex of withswap: gr|eat rge|at
    //here we compare "gr" with "at" and "eat" with "rge"
    bool withswap = (
    //left part of first and right part of second 
    isScramble(s1.substr(0,i),s2.substr(n-i)) 

    &&

    //right part of first and left part of second
    isScramble(s1.substr(i),s2.substr(0,n-i)) 
    );



    //if withswap give us right answer then we return true
    //otherwise the for loop do it work
    if(withswap)
    return true;
    //we are not returning false in else case 
    //because we want to check further cases with the for loop
    }


    return mp[key] = false;

    }
    };

    Try solving now
    02
    Round
    Medium
    Video Call
    Duration60 minutes
    Interview date17 May 2022
    Coding problem2

    This was 1st technical round taken by the software engineer. Interviewer was very friendly, he started with his introduction and then asked me to introduce myself.

    1. Longest Palindromic Substring

    Moderate
    35m average time
    65% success
    0/80
    Asked in companies
    AmazonGoldman SachsOptum

    Given a string ’S’ consisting of lower case English letters, you are supposed to return the longest palindromic substring of ‘S’.

    Note that in case of more than one longest palindromic substrings with the same length you need to return the rightmost substring in the given string. For example in string “bbbab”, there are two possible longest palindromic substrings i.e. “bbb” and “bab”, and since you are supposed to return the rightmost substring, so you need to return “bab” as the answer.

    Note:
    A substring is a contiguous sequence of elements within a string (for example, “bcd” is a substring of “abcde” while “bce” is not).
    
    A string is said to be palindrome if the reverse of the string is the same as the actual string. For example, “abba” is a palindrome, but “abbc” is not a palindrome.
    
    Problem approach

    class Solution {
    public String longestPalindrome(String s) {
    //Approach : treat each character as mid of the palindromic string and check if its left and right character are same or not if they are same then decrement left and increment right and after checking it for each charater determine maximum length which is maximum length of palindromic string 
    // To get palindromic substring return substring from start to start + maximum length
    int n = s.length();
    if(n <= 1) return s;
    int maxLen = 1;
    int start = 0;
    //for odd length 
    for(int i=0;i= 0 && r < n && s.charAt(l) == s.charAt(r)){
    l--;
    r++;
    }
    int len = r-l-1;
    if(len > maxLen){
    maxLen = len;
    start = l+1;
    }
    }
    //for Even length 
    for(int i=0;i= 0 && r maxLen){
    maxLen = len;
    start = l+1;
    }
    }
    return s.substring(start,start+maxLen);
    }
    }

    Try solving now

    2. 3Sum

    Moderate
    15m average time
    85% success
    0/80
    Asked in companies
    Goldman SachsAdobeAmazon

    You are given an array/list ARR consisting of N integers. Your task is to find all the distinct triplets present in the array which adds up to a given number K.

    An array is said to have a triplet {ARR[i], ARR[j], ARR[k]} with sum = 'K' if there exists three indices i, j and k such that i!=j, j!=k and i!=j and ARR[i] + ARR[j] + ARR[k] = 'K'.

    Note:
    1. You can return the list of values in any order. For example, if a valid triplet is {1, 2, -3}, then {2, -3, 1}, {-3, 2, 1} etc is also valid triplet. Also, the ordering of different triplets can be random i.e if there are more than one valid triplets, you can return them in any order.
    2. The elements in the array need not be distinct.
    3. If no such triplet is present in the array, then return an empty list, and the output printed for such a test case will be "-1".
    
    Problem approach

    Intuition
    Approach
    Only used two loops and for removeing dublicate triplets used simple javaScript objects.

    Complexity
    Time complexity:
    Space complexity:
    Code
    /**
    * @param {number[]} nums
    * @return {number[][]}
    */
    var threeSum = function(nums) {

    let obj={}
    nums=nums.sort((a,b)=>a-b)
    // console.log(nums)
    for(let start=0;start0){
    right--
    }else if(nums[left]+nums[right]+nums[start]<0){
    left++
    }
    }
    }
    return (Object.values(obj))
    };

    Try solving now
    03
    Round
    Medium
    Video Call
    Duration60 minutes
    Interview date14 May 2022
    Coding problem2

    It was the second technical round taken by the senior software developer. During the interview, the interviewer was very friendly and helpful whenever I had any questions. I was asked to introduce myself after he gave his introduction.

    1. Max Product Count

    Moderate
    35m average time
    70% success
    0/80
    Asked in companies
    American ExpressBank Of AmericaHSBC

    You are given an array 'ARR' of 'N' distinct integers.

    Your task is to find the product 'P' with the highest count('C') of quadruples which follow p * q = r * s where p, q, r, and s are elements of the array with different indexes.

    Note:
    1. Quadruple p*q = r*s is the same as r*s = p*q.
    
    2. If 2 or more products have the same count of quadruples, print the lowest value of the product i.e if (P1, P2) are the 2 products with the same count of such quadruples(C1 = C2) then 'P' = min(P1, P2).
    
    3. If no such quadruple exists('C' = 0), return 0.
    

    Example:

    If the given array is [3, 4, 6, 2, 1], then the answer would be 6 1. Because there are two products 'P' i.e 6 and 12 which have the highest and same count 'C' of quadruples, i.e 'C' = 1. Therefore the lowest value of the product 'P' is the answer i.e 6.
    
    Try solving now

    2. Find power of a number

    Easy
    15m average time
    80% success
    0/40
    Asked in companies
    AmazonQuikrPayPal

    Ninja is sitting in an examination hall. He is encountered with a problem statement, "Find ‘X’ to the power ‘N’ (i.e. ‘X’ ^ ‘N’). Where ‘X’ and ‘N’ are two integers."

    Ninja was not prepared for this question at all, as this question was unexpected in the exam.

    He is asking for your help to solve this problem. Help Ninja to find the answer to the problem.

    Note :

    For this question, you can assume that 0 raised to the power of 0 is 1.
    
    Problem approach

    class Solution {
    public:
    double myPow(double x, int n) {
    if(n==0) return 1;
    if(n<0){
    n = abs(n);
    x = 1/x;
    }
    if(n%2==0) return myPow(x*x,n/2);
    else return x*myPow(x,n-1);
    }
    };

    Try solving now
    04
    Round
    Medium
    Face to Face
    Duration60 minutes
    Interview date17 May 2022
    Coding problem1

    This round was a technical + HR round taken by a senior manager at saleforce. During this interview, they asked a lot of questions about my experience, projects and one coding question.

    1. Combinations

    Moderate
    45m average time
    60% success
    0/80
    Asked in companies
    AmazonFacebookGoogle inc

    Ninja has ‘N’ beautiful paintings labeled from 1 to N.He has to go to an exhibition to showcase ‘K’ paintings. Now, he is confused about which combinations of paintings he should choose.He wants to make all possible combinations of these ‘N’ paintings. Can you help Ninja to make all the possible combinations of N paintings?

    You are given two integers N and K. Your task is to print return all possible combinations of ‘K’ paintings.

    For Example
    For the given if N is 4 and K is 3,the possible combinations are [1,2,3] , [1,2,4] , [2,3,4],[1,3,4] .
    
    Problem approach

    Intuition : Since we are asked to calculate all the possible combinations, hence we have to use backtracking

    Concept : In every backtracking problem, there are two things to keep in mind, which we will explore here as well :

    Base Case : Every problem of backtracking has some base case that tells us at which point we have to stop with the recursion process. In our case, when the size of our array current equals to k i.e. current.size()=k, we stop with the recursion and add it to our final result ans.

    Conditions : There is just one thing to keep in mind here:
    After generating combinations corresponding to a particular number i, proceed to the next element by popping the element from the temporary array current, as we used that already.

    We basically consider a number i, generate the combinations corresponding to it by recursively calling it again, and then we pop that element as we are done with it and proceed to the next!!

    And thats it!! We are done!! 

    Try solving now

    Here's your problem of the day

    Solving this problem will increase your chance to get selected in this company

    Skill covered: Programming

    How do you remove whitespace from the start of a string?

    Choose another skill to practice
    Similar interview experiences
    company logo
    Devops Engineer
    3 rounds | 3 problems
    Interviewed by Amazon
    0 views
    0 comments
    0 upvotes
    company logo
    SDE - 1
    4 rounds | 8 problems
    Interviewed by Amazon
    8962 views
    0 comments
    0 upvotes
    company logo
    Fullstack Developer
    2 rounds | 4 problems
    Interviewed by Amazon
    7905 views
    2 comments
    0 upvotes
    company logo
    SDE - Intern
    1 rounds | 3 problems
    Interviewed by Amazon
    3501 views
    0 comments
    0 upvotes
    Companies with similar interview experiences
    company logo
    Devops Engineer
    2 rounds | 3 problems
    Interviewed by Optum
    541 views
    0 comments
    0 upvotes