Add office photos
Engaged Employer

Amazon

4.1
based on 23.8k Reviews
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by

40+ Interview Questions and Answers

Updated 9 Oct 2024
Popular Designations
Q1. Merge Two Sorted Linked Lists

Given a singly linked list of integers. Your task is to return the head of the reversed linked list.

For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse...read more
View 5 more answers
Q2. Longest Common Subsequence

Given two strings, 'S' and 'T' with lengths 'M' and 'N', find the length of the 'Longest Common Subsequence'.

For a string 'str'(per se) of length K, the subsequences are the strings c...read more

View 3 more answers
Q3. Reverse Linked List

Given a singly linked list of integers. Your task is to return the head of the reversed linked list.

For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked li...read more
View 5 more answers
Q4. Minimum Cost to Buy Oranges

You are given a bag of size 'W' kg and provided with the costs of packets with different weights of oranges as a list/array with the name 'cost'. Every i-th position in the cost denot...read more

View 4 more answers
Discover null interview dos and don'ts from real experiences
Q5. Sum Between Zeroes

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 contain...read more

Add your answer
Q6. Connect N Ropes With Minimum Cost

You have been given 'N' ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. We need to conn...read more

View 2 more answers
Are these interview questions helpful?

Q7. You have given 10 files and you have given a string suggest data structure which ll facilitate efficient search of string in the file if string appears more than ones in that case u have to print line number an...

read more
Ans.

Suggest a data structure for efficient search of a string in 10 files and print line number and file if string appears more than once.

  • Use a hash table to store the file name and line number of each occurrence of the string.

  • Iterate through each file and for each line, check if the string is present and update the hash table accordingly.

  • Print the hash table entries for the string.

Add your answer
Q8. General Questions

1) Explain DNS
2) What is DHCP
3) What is SIP protocol
4) Difference between TCP/UDP
5) Difference between HTTP/HTTPs
6) What is proxy server.
7) Some basics Linux commands
8) What is BCNF in DBMS.

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. Given a binary tree in which the node structure has an additional field called “next” which of pointer to tree node type, fill up this field of each node to point to the next node at the same level (NULL if las...

read more
Ans.

The task is to fill the 'next' field of each node in a binary tree to point to the next node at the same level.

  • Use a level order traversal to process the tree nodes.

  • Maintain a queue to store the nodes at each level.

  • For each node, set its 'next' field to the next node in the queue.

  • If a node is the last node at its level, set its 'next' field to NULL.

Add your answer

Q10. there is an infinite stair case and there are n rounds. in i'th round we can jump i steps at one or discard them. it is given that k'th step is broken , find the max height we can reach with out stepping on the...

read more
Ans.

Given an infinite staircase with a broken kth step, find the maximum height we can reach in n rounds of jumping i steps.

  • We can start by jumping the maximum number of steps in each round until we reach the broken step.

  • After reaching the broken step, we can discard the i steps that would land us on the broken step and jump the remaining steps.

  • We can continue this pattern until we reach the maximum height we can reach without stepping on the broken step.

Add your answer

Q11. You have a dictionary of words. Given a word, print all anagram are in dictionary . State the data structure to be used to solve this problem

Ans.

To find anagrams of a given word in a dictionary, use a hash table to store sorted versions of each word as keys and their corresponding original words as values.

  • Create a hash table to store the anagrams

  • Iterate through each word in the dictionary

  • Sort the characters of the word and use it as a key in the hash table

  • If the key already exists, add the word to the list of values for that key

  • Print the list of values for the given word's sorted characters

Add your answer

Q12. find the nearest greater value of a given value in a BST

Ans.

Find the nearest greater value of a given value in a Binary Search Tree (BST).

  • Start from the root node and compare the given value with the current node's value.

  • If the given value is less than the current node's value, move to the left subtree.

  • If the given value is greater than the current node's value, move to the right subtree.

  • Keep track of the closest greater value encountered while traversing the tree.

  • Return the closest greater value found.

Add your answer

Q13. Given a string of parenthesis, write a function if it is balanced

Ans.

Function to check if a string of parenthesis is balanced

  • Use a stack to keep track of opening parenthesis

  • If a closing parenthesis is encountered, pop from stack and check if it matches

  • If stack is empty and a closing parenthesis is encountered, return False

  • If all parenthesis are matched and stack is empty, return True

Add your answer
Q14. DBMS Question

Tell the ACID properties in DBMS.

Add your answer

Q15. Find the number of occurrences of words in a paragraph

Ans.

Count the occurrences of words in a paragraph.

  • Split the paragraph into words using whitespace as a delimiter.

  • Create a dictionary to store the count of each word.

  • Iterate through the words and increment the count in the dictionary.

  • Return the dictionary with the word counts.

Add your answer

Q16. Find common elements out of two sorted array?

Ans.

Find common elements out of two sorted array

  • Use two pointers to traverse both arrays simultaneously

  • Compare elements at each pointer and move the pointer of the smaller element

  • If elements are equal, add to common elements list and move both pointers

  • Stop when either pointer reaches end of array

Add your answer

Q17. Given a csv file with users and the websites they visited, find the top k most visited website patterns by users

Ans.

Use a combination of sliding window and hashmap to find top k most visited website patterns by users

  • Parse the csv file to extract user and website data

  • Use a sliding window to generate all possible website patterns for each user

  • Use a hashmap to count the frequency of each website pattern

  • Sort the website patterns based on frequency and return the top k patterns

Add your answer

Q18. boundary traversal of a tree

Ans.

Boundary traversal of a tree is the process of visiting the nodes on the boundary of a tree in a specific order.

  • The boundary traversal can be done in three steps: left boundary, leaf nodes, and right boundary.

  • For the left boundary, start from the root and traverse down the left side of the tree until reaching a leaf node.

  • For the leaf nodes, perform an inorder traversal to visit all the leaf nodes of the tree.

  • For the right boundary, start from the rightmost leaf node and trave...read more

View 1 answer

Q19. Convert BST to a Doubly linked list?

Ans.

Convert a Binary Search Tree to a Doubly Linked List.

  • Create a DLL node class with left, right, and data fields.

  • Traverse the BST in-order and add each node to the DLL.

  • Adjust the left and right pointers of each node to create the DLL.

  • Return the head of the DLL.

Add your answer

Q20. Cant say because of NDA, make a package dependency ood.

Ans.

Create a package dependency diagram based on object-oriented design principles.

  • Identify the main classes/modules in the system

  • Determine the relationships between classes/modules (e.g. inheritance, composition, aggregation)

  • Visualize the dependencies between classes/modules using arrows or lines

  • Consider using UML diagrams to represent the package dependency

Add your answer

Q21. Balanced Parenthesis No of brackets to make balanced parenthesis Maximum Units on a truck

Ans.

The question is about balanced parenthesis and finding the maximum units on a truck.

  • To check if a string of brackets is balanced, we can use a stack data structure.

  • To find the maximum units on a truck, we need to sort the items by weight and then start adding them to the truck until it reaches its maximum capacity.

Add your answer

Q22. 1. A variation of nodes at a distance of K

Ans.

A question about finding nodes at a distance of K from a given node in a graph.

  • Use BFS or DFS to traverse the graph and keep track of the distance from the starting node.

  • Maintain a visited set to avoid revisiting nodes.

  • Return all nodes at distance K from the starting node.

  • Example: Find all nodes at distance 2 from node A in a graph.

Add your answer

Q23. Linked list and operations for array on linked list

Ans.

Linked list is a data structure where each element points to the next element. Operations like insertion, deletion, traversal can be performed on linked lists.

  • Linked list is a linear data structure where elements are stored in nodes. Each node contains data and a reference to the next node.

  • Operations on linked list include insertion, deletion, traversal, and searching.

  • For example, to insert a new node at the beginning of a linked list, create a new node with the data and poin...read more

Add your answer

Q24. Graph problems with popular algo implementations

Ans.

Graph problems and popular algo implementations

  • Shortest Path: Dijkstra's, Bellman-Ford, Floyd-Warshall

  • Minimum Spanning Tree: Prim's, Kruskal's

  • Topological Sorting: Kahn's, DFS

  • Max Flow: Ford-Fulkerson, Edmonds-Karp

  • Travelling Salesman Problem: Held-Karp, Christofides

  • Graph Coloring: Greedy, Backtracking

Add your answer

Q25. DSA question. Detect Symmetric Binary tree.

Ans.

Detect if a binary tree is symmetric.

  • Check if the left and right subtrees are mirror images of each other.

  • Use a recursive approach to compare corresponding nodes.

  • Base case: if both nodes are null, return true.

  • If one node is null and the other is not, return false.

  • If the values of the nodes are not equal, return false.

  • Recursively check if the left subtree of the left node is symmetric to the right subtree of the right node.

  • Recursively check if the right subtree of the left nod...read more

Add your answer

Q26. DSA only with higher difficulty with SDE3.

Ans.

The question is about advanced data structures and algorithms for a senior software engineer role.

  • Focus on advanced data structures like AVL trees, B-trees, and tries

  • Discuss complex algorithms like Dijkstra's algorithm, A* search algorithm, and dynamic programming

  • Highlight experience with optimizing time and space complexity

  • Provide examples of solving challenging coding problems or implementing complex algorithms

Add your answer

Q27. Merge point of twi linked list.

Ans.

Finding the merge point of two linked lists.

  • Traverse both linked lists to find their lengths.

  • Move the pointer of the longer list ahead by the difference in lengths.

  • Iterate both lists simultaneously until the merge point is found.

Add your answer

Q28. How to traverse a linked list

Ans.

Traversing a linked list involves iterating through each node starting from the head until the end is reached.

  • Start at the head node

  • Iterate through each node by following the 'next' pointer until the end is reached

  • Perform desired operations on each node as needed

Add your answer

Q29. 1. DP + Sliding window problem

Ans.

DP + Sliding window problem

  • Dynamic Programming (DP) is a technique to solve optimization problems by breaking them down into smaller subproblems

  • Sliding window is a technique to solve problems by maintaining a window of elements in an array or string

  • Combining DP and sliding window can be useful in solving problems that require both techniques

Add your answer

Q30. find treasury island DFS 2D array

Ans.

Treasury Island can be found using Depth First Search on a 2D array of strings.

  • Implement a Depth First Search algorithm to traverse the 2D array of strings

  • Start from a specific point on the island and explore all possible paths

  • Keep track of visited cells to avoid infinite loops

  • Return the path that leads to the treasury on the island

Add your answer

Q31. Sum on node in binary tree

Ans.

Recursively sum the values of nodes in a binary tree

  • Use a recursive function to traverse the tree and add the values of each node

  • Base case: if the current node is null, return 0

  • Recursive step: return the sum of current node value, left subtree sum, and right subtree sum

Add your answer

Q32. How to design amazon

Ans.

Designing Amazon involves creating a user-friendly e-commerce platform with a vast product selection, efficient search and recommendation algorithms, secure payment processing, and reliable delivery logistics.

  • Develop a user-friendly interface for easy navigation and product search

  • Implement recommendation algorithms based on user behavior and preferences

  • Integrate secure payment processing systems to protect customer information

  • Establish efficient delivery logistics for timely ...read more

Add your answer

Q33. how to invert 25 bst

Ans.

To invert a binary search tree (BST), swap the left and right children of each node recursively.

  • Start from the root node and recursively swap the left and right children of each node.

  • Repeat this process for all nodes in the BST.

  • The final result will be the inverted BST.

Add your answer

Q34. create a minesweeper game

Ans.

Create a classic minesweeper game with a grid of cells to uncover without hitting any mines.

  • Create a grid of cells with hidden mines randomly placed

  • Allow the player to uncover cells and reveal numbers indicating nearby mines

  • Implement logic to end the game if a mine is uncovered or all non-mine cells are revealed

Add your answer

Q35. Reverse a linked list

Ans.

Reverse a linked list

  • Iterate through the linked list and change the direction of the pointers

  • Use three pointers to keep track of current, previous and next nodes

  • Recursively reverse the linked list

Add your answer

Q36. Number of Islands (on lc)

Ans.

Count the number of islands in a 2D grid where '1' represents land and '0' represents water.

  • Iterate through the grid and for each '1' encountered, perform a depth-first search to mark all adjacent '1's as visited.

  • Increment the island count for each new island found.

  • Ensure to handle boundary conditions and visited cells properly to avoid infinite loops.

Add your answer

Q37. sort linked lists

Ans.

Sorting linked lists involves rearranging the nodes in a specific order.

  • Use a sorting algorithm such as merge sort or quick sort to rearrange the nodes in the linked list.

  • Iterate through the linked list and compare each node with the next one to determine the correct order.

  • Consider the time complexity of the sorting algorithm to ensure efficient sorting of the linked list.

Add your answer

Q38. bus transit system design

Ans.

Designing a bus transit system involves planning routes, schedules, stops, and ticketing systems.

  • Consider the population density and traffic patterns of the area to determine the number and frequency of bus routes.

  • Create a network of bus stops strategically located near residential areas, commercial centers, and transportation hubs.

  • Implement a reliable ticketing system that allows for cashless payments and offers options for daily, weekly, and monthly passes.

  • Integrate real-ti...read more

Add your answer

Q39. Subsequences of arrays

Ans.

Subsequences of arrays are all possible combinations of elements in an array.

  • A subsequence can be of any length, including 0 and the entire array.

  • The order of elements in a subsequence must be maintained.

  • The number of possible subsequences of an array of length n is 2^n.

  • For example, the subsequences of [1, 2, 3] are [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3].

Add your answer

Q40. Troubleshoot a problem

Ans.

To troubleshoot a problem, identify the issue, gather information, analyze data, and implement a solution.

  • Identify the problem by asking questions and gathering information

  • Analyze data to determine the root cause of the problem

  • Implement a solution by testing and verifying the fix

  • Document the problem and solution for future reference

Add your answer

Q41. Merge sort implementation

Ans.

Merge sort is a divide and conquer algorithm that divides the input array into two halves, sorts them, and then merges them back together.

  • Divide the array into two halves recursively

  • Sort each half using merge sort

  • Merge the sorted halves back together

Add your answer

More about working at Amazon

Top Rated Mega Company - 2024
Top Rated Company for Women - 2024
Top Rated Internet/Product Company - 2024
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at null

based on 31 interviews in the last 1 year
3 Interview rounds
Coding Test Round
Technical Round 1
Technical Round 2
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Engineer Interview Questions from Similar Companies

3.5
 • 160 Interview Questions
4.2
 • 17 Interview Questions
3.7
 • 15 Interview Questions
3.1
 • 12 Interview Questions
3.6
 • 10 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter