title-img


Break String Into Words - Amazon Top Interview Questions

Given a list of lowercase alphabet strings words and a lowercase alphabet string s, return whether or not the string can be broken down using the list of words. It's not required to use all of the words and you can reuse words. Example 1 Input words = ["quick", "brown", "the", "fox"] s = "thequickbrownfox" Output True Explanation We can break the string down into "the quick brown fox". Example 2 Input words = ["hello", "world"] s = "hellofoobarworld" Output

View Solution →

Calculator - Amazon Top Interview Questions

Given a string s representing a mathematical expression with"+", "-", "/", and "*", evaluate and return the result. Note: "/" is integer division. Can you implement without using eval? Example 1 Input s = "1+2*4/6" Output 2 Explanation 1 + ((2 * 4) / 6) = 2

View Solution →

Create Largest Number From a List - Amazon Top Interview Questions

Given a list of integers nums, rearrange its order to form the largest possible integer and return it as a string. Constraints n ≤ 1,000 where n is the length of nums nums[i] ≤ 1,000 Example 1 Input nums = [10, 7, 76, 415] Output "77641510" Example 2 Input nums = [961, 745, 331, 794, 923] Output "961923794745331" Example 3 Input nums = [45, 14, 70, 67, 95] Output "9570674514" Example 4 Input nums = [70, 5, 94, 18, 78] Output "9

View Solution →

Crush Consecutive Numbers - Amazon Top Interview Questions

You are given a list of positive integers nums and a positive integer k. Consider an operation where you merge exactly k consecutive numbers, which costs the sum of those numbers. Given that you can make any number of operations, return the minimum cost necessary to merge all the numbers into one number. If it's not possible, return -1. Constraints n ≤ 40 where n is the length of nums 2 ≤ k ≤ 40 nums[i] ≤ 100 Example 1 Input nums = [1, 2, 4, 3, 2] k = 3 Output

View Solution →

Dictionary Nomad - Amazon Top Interview Questions

You are given a list of strings dictionary and two strings start and end. You want to reach from start to end by modifying one character at a time and making sure each resulting word is also in the dictionary. Words are case-sensitive. Return the minimum number of steps it would take to reach end. Return -1 if it's not possible. Constraints 0 ≤ n * m ≤ 300,000 where n is the length of dictionary and m is the length of the longest string Example 1 Input dictionary = ["day", "say

View Solution →