## Detect the Only Duplicate in a List - Amazon Top Interview Questions

You are given a list nums of length n + 1 picked from the range 1, 2, ..., n. By the pigeonhole principle, there must be a duplicate. Find and return it. There is guaranteed to be exactly one duplicate. Bonus: Can you do this in O(n) time and O(1) space? Constraints n ≤ 10,000 Example 1 Input nums = [1, 2, 3, 1] Output 1 Example 2 Input nums = [4, 2, 1, 3, 2] Output 2

## Minimum Bracket Addition - Amazon Top Interview Questions

Given a string s containing brackets ( and ), return the minimum number of brackets that can be inserted so that the brackets are balanced. Constraints n ≤ 100,000 where n is the length of s Example 1 Input s = ")))((" Output 5 Explanation We can insert ((( to the front and )) to the end

## Equalize List Sums with Minimal Updates - Amazon Top Interview Questions

You are given two lists of integers a and b where every element in both lists is between 1 to 6. Consider an operation where you pick a number in either a or b and update its value to a number between 1 to 6. Return the minimum number of operations required such that the sum of a and b are equal. If it's not possible, return -1. Constraints n ≤ 100,000 where n is the length of a m ≤ 100,000 where m is the length of b Example 1 Input a = [1, 5] b = [6, 5, 5] Output 2

## FizzBuzz - Amazon Top Interview Questions

Given an integer n, return a list of integers from 1 to n as strings except for multiples of 3 use “Fizz” instead of the integer and for the multiples of 5 use “Buzz”. For integers which are multiples of both 3 and 5 use “FizzBuzz”. Constraints 0 ≤ n ≤ 100,000 Example 1 Input n = 15 Output ["1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"]

## Longest Consecutive Duplicate String - Amazon Top Interview Questions

Given a lowercase alphabet string s, return the length of the longest substring with same characters. Constraints 0 ≤ n ≤ 100,000 where n is the length of s Example 1 Input s = "abbbba" Output 4 Explanation The longest substring is "bbbb". Example 2 Input s = "aaabbb" Output 3