title-img


Largest Sum of Non-Adjacent Numbers in Circular List - Amazon Top Interview Questions

You are given a list of integers nums representing a circular list (the first and the last elements are adjacent). Return the largest sum of non-adjacent numbers. Constraints n ≤ 100,000 where n is the length of nums. Example 1 Input nums = [9, 2, 3, 5] Output 12 Explanation We can take 9 and 3. Note that we can't take 9 and 5 since they are adjacent.

View Solution →

Largest K Sublist Sum - Amazon Top Interview Questions

You are given a list of integers nums, and an integer k, which represents a large list of nums concatenated k times. Return the sum of the sublist with the largest sum. The sublist can be empty. Constraints 0 ≤ n ≤ 100,000 where n is the length of nums. 0 ≤ k ≤ 10,000 Example 1 Input nums = [1, 3, 4, -5] k = 1 Output 8 Explanation We can take the sublist [1, 3, 4] Example 2 Input nums = [1, 3, 4, -5] k = 2 Output 11 Explanation We can take the s

View Solution →

Ugly Number Sequel - Amazon Top Interview Questions

Consider a sequence of sorted integers whose prime factors only include 2, 3 or 5. The first few terms are 1, 2, 3, 4, 5, 6, 8, 9, 10. Given an integer n, return the nth (0-index) term of the sequence. Constraints 0 ≤ n ≤ 100,000 Example 1 Input n = 5 Output 6 Explanation Since the first six terms are 1, 2, 3, 4, 5, 6.

View Solution →

Add Binary Numbers - Amazon Top Interview Questions

Given two strings a and b that represent binary numbers, add them and return their sum, also as a string. The input strings are guaranteed to be non-empty and contain only 1s and 0s. 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" b = "1" Output "10" Example 2 Input a = "111" b = "1" Output "1000"

View Solution →

Integer to Roman Numeral - Amazon Top Interview Questions

Given an integer n, return its corresponding Roman numeral. Roman numerals contain the symbols representing values in the following list: "I" = 1 "V" = 5 "X" = 10 "L" = 50 "C" = 100 "D" = 500 "M" = 1000 Symbols are typically written largest to smallest, from left to right, and can be computed by summing the values of all the symbols. However, in some cases, when a symbol of lower value is to the left of a symbol of higher value, then the lower value is subtracted from the higher o

View Solution →