## Rotation Groups - Amazon Top Interview Questions

A rotation group for a string contains all of its unique rotations. For example, "123" can be rotated to "231" and "312" and they are all in the same rotation group. Given a list of strings words, group each word by their rotation group, and return the total number of groups. Constraints n ≤ 200 where n is the length of words. Example 1 Input words = ["abc", "xy", "yx", "z", "bca"] Output 3 Explanation There are three rotation groups: ["abc", "bca"] ["xy

View Solution →## Pascal's Triangle - Amazon Top Interview Questions

Given an integer n, return the nth (0-indexed) row of Pascal's triangle. Pascal's triangle can be created as follows: In the top row, there is an array of 1. Each subsequent row is created by adding the number above and to the left with the number above and to the right, treating empty elements as 0. Example 1 Input n = 3 Output [1, 3, 3, 1] Explanation This is row 3 in [1] [1, 1] [1, 2, 1] [1, 3, 3, 1]

View Solution →## Unidirectional Word Search - Amazon Top Interview Questions

Given a two-dimensional matrix of characters board and a string target, return whether the target can be found in the matrix by going left-to-right, or up-to-down unidirectionally. Constraints n, m ≤ 250 where n is the number of rows and columns in board k ≤ 250 where k is the length of word Example 1 Input board = [ ["H", "E", "L", "L", "O"], ["A", "B", "C", "D", "E"] ] word = "HELLO" Output True Example 2 Input board = [ ["x", "z", "d", "x"],

View Solution →## In-Place Move Zeros to End of List - Amazon Top Interview Questions

Given a list of integers nums, put all the zeros to the back of the list by modifying the list in-place. The relative ordering of other elements should stay the same. Can you do it in \mathcal{O}(1)O(1) additional space? Constraints 0 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [0, 1, 0, 2, 3] Output [1, 2, 3, 0, 0] Explanation Note that [1, 2, 3] appear in the same order as in the input.

View Solution →## Roomba - Amazon Top Interview Questions

A Roomba robot is currently sitting in a Cartesian plane at (0, 0). You are given a list of its moves that it will make, containing NORTH, SOUTH, WEST, and EAST. Return whether after its moves it will end up in the coordinate (x, y). Constraints n ≤ 100,000 where n is length of moves Example 1 Input moves = ["NORTH", "EAST"] x = 1 y = 1 Output True Explanation Moving north moves it to (0, 1) and moving east moves it to (1, 1) Example 2 Input moves = [

View Solution →