title-img


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

View Solution →

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

View Solution →

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"]

View Solution →

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

View Solution →

Generate Anagram Substrings - Amazon Top Interview Questions

You are given a lowercase alphabet string s. Return all substrings in s where there is another substring in s at a different location that is an anagram. Return the list sorted in lexicographic order. Constraints 1 ≤ n ≤ 100 where n is the length of s Example 1 Input s = "aba" Output ["a", "a", "ab", "ba"] Explanation We have "a" and "a" which are anagrams. Also, "ab" and "ba" are anagrams.

View Solution →