Uncategorized · 5 2 月, 2024 0

最新亚马逊 Amazon OA 真题 02/06/24


Code question 1

A recently launched supplemental typing keypad gained significant popularity on Amazon Shopping due to itsfexibility.

This keypad can be connected to any electronic device and has 9 buttons, where each button can have up to 3 lowercase English letters. The buyer has the freedom to choose which letters to place on a button while ensuring that the arrangement is valid, A keypad design is said to be valid if :

  1. All 26 letters of the English alphabet exist on the keypad.
  2. Each letter should be mapped to exactly one button.
  3. A button can have most 3 letters mapped to it.

Examples of some valid keypad designs are:

In the left keypad, the word “hello” can be typed using the following button presses: [3] twice (prints ‘h’), [2] twice (prints ‘e’), [4] thrice (prints ‘l’), [4] thrice (prints ‘l’), [5] thrice (prints ‘o’). Thus, the total number of button presses is 2 + 2 + 3 + 3 + 3 = 13.

In the right keypad, “hello” can be typed using the following button presses: [5] once (prints ‘h’), [7] once (prints ‘e’), [6] twice (prints ‘l’), [6] twice (prints ‘l’), [2] twice (prints ‘o’). Thus, the total number of button presses is 1 + 1 + 2 + 2 + 2 = 8.

The keypad click count is defined as the number of button presses required to print a given string. To send messages faster, customers tend to set the keypad design in a way that minimizes the keypad click count while maintaining its validity.

Given a string letters consisting of lowercase English letters only, the goal is to find the minimum keypad click count.


letters = “abacadelghibj”

One of the optimal keypad designs to minimize the keypad click count is:

Code question 2

Amazon rewards its new users with a discount coupon that can be appllied to their first purchase. Some users create more than one account in order to receive the offer multiple times. It was found that their new usernames are only a permutation of their real names.

For examples, if the real usernames of the users are realNames= [“abc”, “def”]and the list of all usernames is allNames = [“bca” “abc”, “cba”,”def”], then the user “abc” must have made multiple accounts as there are three permutations of “abc” in the list of all usernames.

Given an array of realNames an array allNames of usernames for each account identify the names of users who created accounts more than once. The goal is to return the array of real names of these users in lexicographical order. lf there are no such names, return an array containing only the string “None”.

Please note that:

  • lt is guaranteed that no two real names are permutations of each other.
  • For the variable realNames, each value is unique, and indicates an individual person.
  • Each name in allNames is a permutation of some name in realNames
  • There may be some names in realNames without a permutation in allNames
  • lt is possibie that some users may create an account using fake names only.

For example, the length of reaiNames n=3 and the length of allNames m=5.

realNames = ["alice", "bob", "terry"]
allNames = ["celia", "alice", "retry", "bob", "terry"]

A permutation of “alice” occurs twice in allNames as “alice” and “celia”.

A permutation of “bob” occurs once

A permutation of “terry” occurs twice as “terry” and “retry”

The real names with more than one occurrence in allNames are “alice” and “terry”. Return them in lexicographical order, [“alice”, “terry”].

Note: LLexicographical order is ordering strings in the dictionary or alphabetical order. For example, string “hacker” comes before string “rank” in lexicographical order.

A permutation of a string is another string that contains the same characters, only the order of characters can be different.

Function Description:

Complete the function findRecurringNames below.

def findRecurringNames(realNames, allNames):
    # Function logic goes here

findRecurringNames has the following parameters:

  • realNames (string[]): the real user names.
  • allNames (string[]): all registered user names.


  • string[]: the distinct real names of users with multiple registrations in lexicographical order.



We also provide consultation and support services for OA and VO. If needed, please feel free to contact us: