title-img


Add One to List - Amazon Top Interview Questions

You are given a list of integers nums, representing a decimal number and nums[i] is between [0, 9]. For example, [1, 3, 9] represents the number 139. Return the same list in the same representation except modified so that 1 is added to the number. Constraints 1 ≤ n ≤ 100,000 where n is the length of nums. Example 1 Input nums = [1, 9, 1] Output [1, 9, 2] Example 2 Input nums = [9] Output [1, 0]

View Solution →

Lexicographically Largest Mountain List - Amazon Top Interview Questions

You are given three positive integers n, lower, and upper. You want to create a list of length n that is strictly increasing and then strictly decreasing and all the numbers are between [lower, upper], inclusive. Each of the increasing and decreasing parts should be non-empty. Return the lexicographically largest list possible, or the empty list if it's not possible. Constraints 3 ≤ n ≤ 100,000 1 ≤ lower ≤ upper < 2 ** 31 Example 1 Input n = 5 lower = 2 upper = 6 Output

View Solution →

Reverse Words - Amazon Top Interview Questions

Given a string s of words delimited by spaces, reverse the order of words. Constraints n ≤ 100,000 where n is the length of s Example 1 Input sentence = "hello there my friend" Output "friend my there hello"

View Solution →

Sum of Two Numbers Less Than Target - Amazon Top Interview Questions

Given a list of integers nums and an integer target, return the sum of the largest pair of numbers in nums whose sum is less than target. You can assume that there is a solution. Constraints 2 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [5, 1, 2, 3] target = 4 Output 3 Explanation Sum of the largest pair of numbers less than 4 is 1 + 2 = 3.

View Solution →

Longest Common Prefix - Amazon Top Interview Questions

Given a list of lowercase alphabet strings words, return the longest common prefix. Example 1 Input words = ["anthony", "ant", "antigravity"] Output "ant" Explanation "ant" is the longest common prefix between the three strings.

View Solution →