Amazon
Firepro Systems Interview Questions and Answers
Q1. Given a binary tree, count the number of occurrences where there are two nodes with the same horizontal distance. To make it clearer, if we assume each node in a cell of a matrix, then count the number of occur...
read moreCount occurrences of two nodes with same horizontal distance in a binary tree
Traverse the tree using BFS or DFS and keep track of horizontal distance of each node
Store nodes with same horizontal distance in a hash table and increment count if collision occurs
Recursively traverse left and right subtrees with updated horizontal distance
Time complexity: O(n), Space complexity: O(n)
Q2. Given an array and a number, check whether there are any 3 elements in the array which add up to the given number
Check if any 3 elements in an array add up to a given number
Sort the array in ascending order
Use nested loops to iterate through all possible combinations of 3 elements
Check if the sum of the 3 elements equals the given number
Return true if a match is found, else false
Q3. What are the things you will consider (both from Developer’s perspective and User perspective) while trying to develop an application for computer aided competitive examinations like CAT, GMAT etc
Considerations for developing an application for computer aided competitive exams
User-friendly interface for easy navigation
Accurate and reliable question bank
Timed tests to simulate real exam conditions
Option to save and resume tests
Detailed performance analysis and feedback
Compatibility with different devices and operating systems
Regular updates and bug fixes
Developer should consider the security of the application to prevent cheating
User perspective: The application should...read more
Q4. Given a singly linked list, write a recursive method to reverse every 3 nodes in the list. I did not write a clean code for this. He moved on because of lack of time
Reverse every 3 nodes in a singly linked list using recursion
Create a recursive function that takes in a node and a count
If count is less than 3, return the node
Reverse the first 3 nodes and call the function recursively with the 4th node and count 1
Connect the reversed nodes to the rest of the list
Return the new head of the reversed list
Q5. Write some test methods for stress testing of Furniture class
Test methods for stress testing of Furniture class
Create a large number of Furniture objects and check for memory leaks
Simulate heavy usage by continuously calling methods and check for performance issues
Test the Furniture class with maximum allowed input values and check for any errors or crashes
Q6. Given a linked list, write a program to check if it is a palindrome
Program to check if a linked list is a palindrome
Traverse the linked list and push each element onto a stack
Traverse the linked list again and compare each element with the top of the stack
If all elements match, the linked list is a palindrome
Q7. Given a number, find the nearest perfect square(modified binary search)
Given a number, find the nearest perfect square using modified binary search.
Start with low=0 and high=num.
While low<=high, find mid=(low+high)/2.
If mid*mid==num, return mid.
If mid*mid
If mid*mid>num, update high=mid-1.
Return the closest perfect square to num.
More about working at Amazon
Reviews
Interviews
Salaries
Users/Month