Amazon OA Suggest approach

2)Check if a given list contains all the values of other list in the same sequence. The question was a shopping list has items and one other coupon List<List<>> of items. If the items in shopping list are same to the coupon list in the same order than the list return 1 else 0. If the coupon has item as "anything" then you can assume it as any item.

Could any one suggest an approach for the question 2?

Please post your approach as I want to know how can this question be solved:
Example: shopping list={Apple, Mango, Apple, Banana, Kiwi, Grapes, Watermelon}
Coupon list{
{Apple, Mango},
{Banana, Anything, Grapes}
}
If everything in the coupon list match with the shopping list in the same order than the coupon will apply else it wont. In the coupon list the sublists have to match as is but there cna be more elements between two lists.

Comments (4)