Round 1
Questions:
- AWS stores grayscale images as an array of white and black pixels. The image is stored as a binary string where a white pixel is represented by '1', and a black pixel is represented by '0'. The reverse of the image is represented as the reverse of this binary representation. For example, the reverse of "11010" is "01011". They want to store the reverse of each image as a backup. In order to reproduce the reverse from the original, the following operation can be performed any number of times: remove any character from the string and append it to the end of the string, i.e., choose any pixel and shift it to the end of the string. Given the binary representation of pixels denoted by image, find the minimum number of operations needed to produce its reverse.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 2
Questions: 2. Amazon has a cluster of n servers. Some are in the OFF state while others are ON. The developers responsible for maintaining the servers have access to a special operation to change the states. In one operation, they can choose a contiguous sequence of servers and flip their states, i.e., ON to OFF and vice versa. Due to operational constraints, this operation can be performed on the cluster a maximum of k times. Given a binary string server_states, of length n, where '1' represents ON, '0' represents OFF, and an integer k, find the maximum possible number of consecutive ON servers after at most k operations.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 3
Questions: 5. Select prefix of any length from an array and decrement each element in that prefix length by 1. Make sure no element becomes negative. Count maximum number of zeros after all possible operations.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 4
Questions: 6. Amazon has multiple delivery centers and delivery warehouses all over the world. The world is represented by a number line from -10^9 to 10^9. There are n delivery centers, the ith one at location center[i]. A location x is called a suitable location for a warehouse if it is possible to bring all the products to that point by traveling a distance of no more than d. At any one time, products can be brought from one delivery center and placed at point x. Given the positions of n delivery centers, calculate the number of suitable locations in the world, that is, calculate the number of points x on the number line (-10^9 < x < 10^9) where the travel distance required to bring all the products to that point is less than or equal to d. Note: The distance between point x and center[i] is |x - center[i]|. Example Given n= 3, center = [-2, 1, 0], d = 8.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 5
Questions: 7. The sum of k should be less than or equal to the threshold. The question was to find the number of elements that should be removed to make the sum of every k elements in the array less than k. To solve, one can sort the array and remove items if k maximum weighted items summed to be greater than the threshold.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 6
Questions: 8. HackerLand Sports Club wants to send a team for a relay race. There are n racers in the group indexed from 0 to n. The ith racer has a speed of speed[i] units. The coach decided to send some contiguous subsegments of racers for the race, i.e., racers with index i, i+1, +2..., such that each racer has the same speed in the group to ensure smooth baton transfer. To achieve the goal, the coach decided to remove some racers from the group such that the number of racers with the same speed in some contiguous segment is maximum. Given the array, racers, and an integer k, find the maximum possible number of racers in some contiguous segment of racers with the same speed after at most k racers are removed. Example: Suppose n = 6, k=2, and speed = [1, 4, 4, 2, 2, 4]. It is optimal to remove the two racers with speed 2 to get the racers [1, 4, 4, 4]. Each racer with speed 4 can now be sent as they are in a contiguous segment. A maximum of 3 racers can be sent for the relay race.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 7
Questions: 9. Amazon Care is a healthcare and wellbeing portal for its employees. To promote physical fitness, on the portal they launched a "GetFit" tournament consisting of n sprints. Each sprint lasts for a given number of days and includes several tasks such as push-ups, running, etc. Some tasks are scheduled for each day of the sprint. The ith sprint lasts for days[i] days, and each sprint starts just after the other. During each sprint, completing the required tasks scheduled on the jth day of the sprint earns the participant j points. The tournaments are periodic, i.e., as soon as the last sprint of a tournament ends, the first sprint of the next tournament begins. Each tournament, however, has the same schedule of sprints. More formally, the tournament schedule can be considered cyclic in nature and after the last sprint, the first sprint starts again. An employee decides to participate. However, due to a tight schedule, the employee cannot complete all tasks every day. Instead, the employee will complete the tasks of exactly k consecutive days, hoping to achieve the maximum number of points. Given the sprint days of n sprints, and the number of days for which the employee competes for k, find the maximum points the employee can score. The training can start and end on any day of any sprint. Note: k is guaranteed to be less than the total number of days for which the sprints last. Also, it is not necessary to start and end the training in the same tournament.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 8
Questions: 10. You are given a list of positive integers. Find the max number of elements that can be turned negative such that the cumulative sum of the integers up to that index still remains positive.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.
Round 9
Questions: 11. I have an array of size n and am given an integer limit k. I have to return the maximum length of a subarray where each element in that subarray exceeds the value of (k / length of that subarray).
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.