Divisible Numbers - Amazon Top Interview Questions
You are given integers n, a, b, and c. Return the nth (0-indexed) term of the sorted sequence of integers divisible by a, b or c. Note that by convention the first term of any sequence always starts with 1. Example 1 Input n = 8 a = 2 b = 5 c = 7 Output 12 Explanation The first 9 terms of the sequence are [1, 2, 4, 5, 6, 7, 8, 10, 12]
View Solution →Farthest Point From Water - Amazon Top Interview Questions
You are given a matrix matrix of 0s and 1s where 0 represents water and 1 represents land. Find the land with the largest Manhattan distance from water and return this distance. If there is no land or no water in the board, return -1. Constraints n, m ≤ 100 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [1, 1, 0], [1, 1, 0], [0, 0, 1] ] Output 2 Explanation grid[0][0] has a Manhattan distance of 2 to water. Exam
View Solution →Frequency Stack - Amazon Top Interview Questions
Implement a frequency stack with the following methods: FrequencyStack() constructs a new instance of a frequency stack append(int val) appends val to the stack pop() pops and returns the most frequent element in the stack. If there's more than one most frequent element, the one that's closer to the top of the stack should be popped first. You can assume that for pop, the stack is non-empty when they are called. Constraints n ≤ 100,000 where n is the number of methods that will be ca
View Solution →Integer to English - Amazon Top Interview Questions
Given a non-negative integer num, convert it to an English number word as a string. num will be less than one trillion. Constraints 0 ≤ num < 10 ** 12 Example 1 Input num = 523 Output "Five Hundred Twenty Three" Example 2 Input num = 823418 Output "Eight Hundred Twenty Three Thousand Four Hundred Eighteen" Example 3 Input num = 700 Output "Seven Hundred"
View Solution →Job Scheduling to Minimize Difficulty - Amazon Top Interview Questions
You are given a list of integers jobs and an integer k. You want to finish all jobs in k days. The jobs must be done in order and a job must be done each day. The difficulty of job i is jobs[i] and the difficulty of doing a list of jobs on a day is defined to be the maximum difficulty job performed on that day. Return the minimum sum of the difficulties to perform the jobs over k days. Constraints n ≤ 500 where n is the length of jobs k ≤ 10 Example 1 Input jobs = [1, 2,
View Solution →