title-img


Contained Interval - Amazon Top Interview Questions

You are given a two-dimensional list of integers intervals where each element is an inclusive interval [start, end]. Return whether there's an interval which contains another interval. Constraints n ≤ 100,000 where n is the length of intervals. Example 1 Input intervals = [ [1, 3], [4, 10], [4, 8], [9, 9] ] Output True Explanation [4, 10] contains [4, 8]. Example 2 Input intervals = [ [1, 3], [4, 10], [7, 12] ] Output F

View Solution →

Consecutive Ones - Amazon Top Interview Questions

You are given a list of integers nums which contains at least one 1. Return whether all the 1s appear consecutively. Constraints 1 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [0, 1, 1, 1, 2, 3] Output True Explanation All the 1s appear consecutively here in the middle.

View Solution →

Palindromic Integer - Amazon Top Interview Questions

Given a non-negative integer num, return whether it is a palindrome. Bonus: Can you solve it without using strings? Constraints num < 2 ** 31 Example 1 Input num = 121 Output True Example 2 Input num = 20200202 Output True Example 3 Input num = 43 Output False

View Solution →

Rotate List Left by K - Amazon Top Interview Questions

Write a function that rotates a list of numbers to the left by k elements. Numbers should wrap around. Note: The list is guaranteed to have at least one element, and k is guaranteed to be less than or equal to the length of the list. Bonus: Do this without creating a copy of the list. How many swap or move operations do you need? Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 2, 3, 4, 5, 6] k = 2 Output [3, 4, 5, 6, 1, 2] Exa

View Solution →

Square of a List - Amazon Top Interview Questions

Given a list of integers sorted in ascending order nums, square the elements and give the output in sorted order. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [-9, -2, 0, 2, 3] Output [0, 4, 4, 9, 81] Example 2 Input nums = [1, 2, 3, 4, 5] Output [1, 4, 9, 16, 25]

View Solution →