BackmediumStack Flipkart

Valid Recipe Ingredient Sequence Solution

Problem Statement

Given two arrays, determine if one array representing a sequence of ingredients is a valid subsequence of another array representing a recipe.

Example 1
Input
[17, 18, 23, 25, 7, 19, 36], [8, 4, 12, 27, 19]
Output
false

Explanation: Step-by-step: Given the recipe [17, 18, 23, 25, 7, 19, 36] and the sequence [8, 4, 12, 27, 19], we can see that the sequence does not match the recipe in the correct order. Therefore, the output should be false.

Example 2
Input
[17, 18, 23, 25, 7, 19, 36], [27, 19]
Output
false

Explanation: Step-by-step: Given the recipe [17, 18, 23, 25, 7, 19, 36] and the sequence [27, 19], we can see that the sequence does not match the recipe in the correct order. Therefore, the output should be false.

Constraints

  • 1 <= sequence length <= 100
  • 1 <= recipe length <= 500
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free