Sort List by Reversing Once - Amazon Top Interview Questions
You are given a list of integers nums. Given that you can first reverse one sublist in nums, return whether you can make the resulting list be arranged in ascending order. Constraints 0 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 3, 3, 7, 6, 9] Output True Explanation If we reverse the sublist [7, 6], then we can sort the list in ascending order: [1, 3, 3, 6, 7, 9]. Example 2 Input nums = [1, 3, 9, 8, 2] Output False Explana
View Solution →Level Order Alternating - Amazon Top Interview Questions
Given a binary tree root, return values of the nodes in each level, alternating from going left-to-right and right-to-left. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [3, [0, null, [2, [1, null, null], null]], [4, null, null]] Output [3, 4, 0, 2, 1]
View Solution →Roman Numeral to Integer - Amazon Top Interview Questions
Given a string numeral representing a Roman numeral, convert it to an integer. 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 Roman numerals are typically written largest to smallest, from left to right, and can be computed by summing up 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
View Solution →Contiguously Increasing Numbers - Amazon Top Interview Questions
Given two integers start and end, return a sorted list of integers such that every number e is between start ≤ e ≤ end and the digits of e are contiguously increasing. For example, 2345 is contiguously increasing while 135 and 321 are not. Constraints 0 ≤ start ≤ end < 2 ** 31 Example 1 Input start = 0 end = 100 Output [1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 23, 34, 45, 56, 67, 78, 89]
View Solution →Subsequence Strings - Amazon Top Interview Questions
Given two lowercase alphabet strings s1 and s2, determine if s1 is a subsequence of s2. Constraints n ≤ 100,000 where n is the length of s1 m ≤ 100,000 where m is the length of s2 Example 1 Input s1 = "ppl" s2 = "apple" Output True Example 2 Input s1 = "ale" s2 = "apple" Output True Example 3 Input s1 = "elppa" s2 = "apple" Output False
View Solution →