Amazon Online Assessment (OA) - Secret Fruit List

A Company is running a promotion. Customers purchased a secret list of fruit will receive prizes. Notice 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, mongo, strawberry, watermelon, mongo]

secretFruitLists = [[orange, mongo], [watermelon, mongo]]

Output: true

Example 2:

Input:

customerPurchasedList = [watermelon, orange, mongo]

secretFruitLists = [[watermelon, anything, mongo]]

Output: true

Example 3:

Input:

customerPurchasedList = [watermelon, apple, orange, mongo]

secretFruitLists = [[watermelon, anything, mongo]]

Output: false

Try it yourself