Amazon Online Assessment (OA) - Secret Fruit List

A company is running a promotion. Customers who purchase a secret list of fruits will receive prizes. Note that the order of the fruits matters.

Also, there can be a keyword anything in the secretFruitList which can be used for any type of fruit.

Examples

Example 1:

Input:

customerPurchasedList = [orange, mango, strawberry, watermelon, mango]

secretFruitLists = [[orange, mango], [watermelon, mango]]

Output: true

Example 2:

Input:

customerPurchasedList = [watermelon, orange, mango]

secretFruitLists = [[watermelon, anything, mango]]

Output: true

Example 3:

Input:

customerPurchasedList = [watermelon, apple, orange, mango]

secretFruitLists = [[watermelon, anything, mango]]

Output: false

Try it yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro
Favorite (idle)