PracHub
QuestionsPremiumLearningGuidesCheatsheetNEW
|Home/Coding & Algorithms/Snowflake

Check if each recipe is a contiguous subsequence

Last updated: Apr 30, 2026

Quick Overview

This question evaluates proficiency in algorithmic sequence matching and contiguous subarray detection, encompassing array/string pattern matching and time/space complexity reasoning.

  • hard
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Check if each recipe is a contiguous subsequence

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given: - An **ordered** ingredient list `ingredients[0..n-1]`. - A list of **m** recipes. Each recipe `recipes[j]` is itself a list of ingredients and is intended to represent a sequence of **consecutive** ingredients. ### Task For each recipe, determine whether it can be formed by taking a **contiguous subarray** of `ingredients` (i.e., there exists an index `s` such that `ingredients[s .. s + len(recipe)-1]` equals the recipe exactly, element by element). Return an array `ans[0..m-1]` of booleans. ### Input - Array `ingredients` (length `n`) - List of arrays `recipes` (total `m` recipes) ### Output - Boolean array `ans`, where `ans[j] = true` if `recipes[j]` appears contiguously in `ingredients`, else `false`. ### Follow-ups 1. How would you solve it if you are allowed only **O(1)** extra space (beyond the input/output)? 2. How would you solve it if `ingredients` arrives as a **data stream** and is too large to store fully? ### Constraints (typical) - `1 <= n <= 2e5` - `1 <= m <= 2e5` - Total length of all recipes `<= 2e5` - Ingredients can be treated as strings or integers.

Quick Answer: This question evaluates proficiency in algorithmic sequence matching and contiguous subarray detection, encompassing array/string pattern matching and time/space complexity reasoning.

Related Interview Questions

  • Solve Array Distance and Wiki Navigation - Snowflake (medium)
  • Implement Document Predicate APIs - Snowflake (medium)
  • Find Shortest Wiki Click Path - Snowflake (medium)
  • Schedule prerequisite classes with retakes - Snowflake (easy)
  • Solve three coding rounds - Snowflake (medium)
Snowflake logo
Snowflake
Jan 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
4
0
Coding Console
Loading...

You are given:

  • An ordered ingredient list ingredients[0..n-1] .
  • A list of m recipes. Each recipe recipes[j] is itself a list of ingredients and is intended to represent a sequence of consecutive ingredients.

Task

For each recipe, determine whether it can be formed by taking a contiguous subarray of ingredients (i.e., there exists an index s such that ingredients[s .. s + len(recipe)-1] equals the recipe exactly, element by element).

Return an array ans[0..m-1] of booleans.

Input

  • Array ingredients (length n )
  • List of arrays recipes (total m recipes)

Output

  • Boolean array ans , where ans[j] = true if recipes[j] appears contiguously in ingredients , else false .

Follow-ups

  1. How would you solve it if you are allowed only O(1) extra space (beyond the input/output)?
  2. How would you solve it if ingredients arrives as a data stream and is too large to store fully?

Constraints (typical)

  • 1 <= n <= 2e5
  • 1 <= m <= 2e5
  • Total length of all recipes <= 2e5
  • Ingredients can be treated as strings or integers.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Snowflake•More Software Engineer•Snowflake Software Engineer•Snowflake Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.