title-img


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 →

Justify Text - Amazon Top Interview Questions

Given a list of words and an integer line length k, return a list of strings which represents each line fully justified, with as many words as possible in each line. There should be at least one space between each word, and pad extra spaces when necessary so that each line has exactly length k. Spaces should be distributed as equally as possible, with any extra spaces distributed starting from the left. If you can only fit one word on a line, then pad the right-hand side with spaces. Ea

View Solution →

Largest Binary Search Subtree in Nodes - Amazon Top Interview Questions

Given a binary tree root, find the largest subtree (the one with the most nodes) that is a binary search tree. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [1, [3, [2, null, null], [5, null, null]], null] Output [3, [2, null, null], [5, null, null]] Explanation The root is not a valid binary search tree, but the tree beginning at 3 is.

View Solution →

Largest Binary Search Subtree in Value - Amazon Top Interview Questions

Given a binary tree root, return the largest sum of a subtree that is also a binary search tree. Constraints 0 ≤ n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [1, [5, [6, null, null], [7, null, null]], [3, [2, null, null], [4, null, null]]] Output 9 Explanation The binary search tree rooted at 3 has the largest sum with 3 + 2 + 4 = 9

View Solution →