Amazon
10+ EPAM Systems Interview Questions and Answers
Q1. Say you're dealing with really long integers. They're too long to fit into a regular datatype, so linked lists are used to store them, with each node of the list containing one digit. Now the problem is, given ...
read moreGiven two linked lists representing long integers, perform addition operation.
Traverse both linked lists simultaneously, starting from the head.
Perform addition of corresponding digits and keep track of carry.
Create a new linked list to store the result.
Handle cases where one list is longer than the other.
Handle the final carry if any.
Q2. Given a linked list (singly-linked, non-circular), swap the kth node with the kth last node in the list. Note that the length of the list is not known.
Swap kth node with kth last node in a singly-linked, non-circular linked list.
Traverse the linked list to find its length or use two pointers to find kth and kth last nodes.
Swap the nodes and update the pointers accordingly.
Handle edge cases such as k being out of bounds or kth and kth last nodes being the same.
Consider using recursion to traverse the linked list.
Q3. long numbers, add the two numbers and store the result in a third linked list. 2/2
Add two long numbers and store the result in a third linked list.
Create a linked list to store the result
Traverse both input linked lists simultaneously, adding corresponding digits
Handle carry over from addition
If one linked list is longer than the other, handle remaining digits
Return the resulting linked list
Q4. Given a Binary Search Tree, print the kth last node in inorder traversal of the tree
To print the kth last node in inorder traversal of a Binary Search Tree, we can use a modified inorder traversal algorithm.
Perform an inorder traversal of the BST, keeping track of the nodes visited in a stack.
Once the traversal is complete, pop k elements from the stack to get the kth last node.
Print the value of the kth last node.
Q5. What are hamming distance and hamming weights? Write code to calculate hamming distance between 2 numbers.
Hamming distance is the number of differing bits between two binary strings. Hamming weight is the number of 1s in a binary string.
Hamming distance is used in error detection and correction codes.
Hamming weight is also known as population count or popcount.
To calculate hamming distance, XOR two numbers and count the number of 1s in the result.
Example: Hamming distance between 1010 and 1110 is 1.
Example: Hamming weight of 1010 is 2.
Q6. List some sorting algorithms. Why time complexity of merge sort is O(nlogn)
Sorting algorithms include bubble sort, insertion sort, selection sort, quick sort, merge sort, etc. Merge sort has O(nlogn) time complexity.
Sorting algorithms are used to arrange data in a specific order.
Merge sort is a divide and conquer algorithm that divides the input array into two halves, sorts each half, and then merges the sorted halves.
The time complexity of merge sort is O(nlogn) because it divides the input array into halves recursively until the base case is reach...read more
Q7. What data structure do you know? Advantages and disadvantages of singly and doubly linked lists
Singly and doubly linked lists are linear data structures used to store and manipulate data.
Singly linked lists use less memory than doubly linked lists
Doubly linked lists allow for traversal in both directions
Singly linked lists are faster for insertion and deletion at the beginning of the list
Doubly linked lists are faster for insertion and deletion in the middle of the list
Both have O(n) time complexity for searching
Q8. Given an array, what is the sum of the products of all subsequences?
The sum of the products of all subsequences in an array of strings.
Calculate the product of all elements in the array
Calculate the product of all possible subsequences
Sum up all the products of subsequences
Q9. What pattern have you followed while building modules.
I have followed the modular design pattern while building modules.
I break down the software into smaller, independent modules that can be easily managed and maintained.
I ensure each module has a clear purpose and well-defined interfaces for communication with other modules.
I use techniques like encapsulation, abstraction, and separation of concerns to create modular designs.
Example: Using the MVC (Model-View-Controller) pattern to separate the presentation, business logic, an...read more
Q10. write a program for Trapping Rain Water . what is time complexity of the program
The program calculates the amount of rainwater that can be trapped between buildings given an array of heights.
Use two pointers to iterate from left and right towards the middle
Keep track of the maximum height on the left and right for each pointer
Calculate the trapped water at each index based on the minimum of the maximum heights on left and right
Sum up the trapped water at each index to get the total trapped water
Q11. write a program to find out Diameter of Tree what is time complexity of the program
Program to find diameter of a tree and its time complexity
Use Depth First Search (DFS) to find the longest path in the tree
Calculate the diameter by summing the heights of the left and right subtrees for each node
Time complexity is O(n) where n is the number of nodes in the tree
Q12. LC: to delete the nth node in a linked list.
Delete the nth node in a linked list.
Traverse the linked list to find the nth node and keep track of the previous node.
Update the previous node's next pointer to skip the nth node.
Free the memory allocated to the nth node.
Q13. System design on my done projects.
Designed a system for a project involving real-time data processing and analysis.
Utilized microservices architecture for scalability and flexibility
Implemented message queues for asynchronous communication between components
Used a combination of relational and NoSQL databases for different data storage needs
Q14. Print boundary nodes of a tree
Print the boundary nodes of a tree.
Boundary nodes are the leftmost and rightmost nodes of each level of the tree and the leaf nodes that are not part of the subtree.
Traverse the tree in a clockwise direction and print the nodes as you encounter them.
Use recursion to traverse the tree and keep track of the level and whether the node is a left or right boundary node.
Q15. Binary Tree medium level problem
The question involves solving a medium level problem related to binary trees.
Understand the basic concepts of binary trees such as nodes, edges, and traversal methods.
Practice implementing common operations on binary trees like insertion, deletion, and searching.
Consider using recursion to solve problems involving binary trees.
An example of a medium level problem could be finding the lowest common ancestor of two nodes in a binary tree.
Q16. Boundary Traversal Of tree
Boundary Traversal Of tree
Boundary traversal of a tree involves visiting the nodes of the tree in a specific order
The order is: left boundary, leaf nodes, and right boundary
We can use a combination of pre-order, in-order, and post-order traversals to achieve this
Start with the root node and recursively traverse the left subtree, printing the nodes
Then traverse the leaf nodes using an in-order traversal
Finally, traverse the right subtree in a post-order traversal and print the...read more
Q17. Possible Parenthesis
The question is asking for the possible combinations of valid parentheses.
Use backtracking to generate all possible combinations of parentheses.
Keep track of the number of open and close parentheses to ensure they are balanced.
Exclude invalid combinations where close parentheses appear before open parentheses.
Q18. Find Peak Element
Find Peak Element
A peak element is an element that is greater than its neighbors
The problem can be solved using binary search
If the middle element is smaller than its neighbors, then there must be a peak on the right side
If the middle element is greater than its neighbors, then there must be a peak on the left side
Repeat the process on the corresponding side until a peak element is found
More about working at Amazon
Interview Process at EPAM Systems
Reviews
Interviews
Salaries
Users/Month