Amplifier Array
Easy · Online assessment (OA) · Full-time
I had a 3-hour coding round with 3 questions. The first one they gave me was pretty straightforward. I got an array of amplifiers where each one multiplies the input signal by its value. Starting from signal strength 1, I needed to find the maximum number of adjacent amplifiers that would produce exactly some target value S. If there was no way to get S from any contiguous subarray, I had to return -1. I went with a sliding window approach since all the values were positive, meaning the product only grows as the window gets bigger, so two pointers worked perfectly. One of the examples was A = {1, 2, 3, 4, 6} with S = 12, which returns 2 because 3 * 4 = 12. Another was A = {2, 1, 3, 4, 6} with S = 12, returning 3 since 1 * 3 * 4 = 12.
