title-img


Lexicographically Smallest Non-Palindromic String - Amazon Top Interview Questions

You are given a lowercase alphabet string s that is a palindrome. Update one character such that s is no longer a palindrome and is lexicographically smallest. Constraints 2 ≤ n ≤ 100,000 where n is the length of s Example 1 Input s = "racecar" Output "aacecar" Explanation We can change the first "r" to "a" to get the

View Solution →

Interleaved Linked List - Amazon Top Interview Questions

Given two linked lists l0 and l1, return the two linked lists interleaved, starting with l0. If there are leftover nodes in a linked list, they should be added to the end. Constraints n ≤ 100,000 where n is the number of nodes in l0 m ≤ 100,000 where m is the number of nodes in l1 Example 1 Input l0 = [7, 8] l1 = [1, 2] Output [7, 1, 8, 2] Example 2 Input l0 = [7, 8] l1 = [1] Output [7, 1, 8]

View Solution →

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 →