PracHub
QuestionsLearningGuidesInterview Prep

Quick Overview

Practice a Snowflake coding interview problem focused on find the nearest target character and support streaming updates. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

  • medium
  • Snowflake
  • Coding & Algorithms
  • Software Engineer

Find the Nearest Target Character and Support Streaming Updates

Company: Snowflake

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an array of characters and a target character, return the distance from each index to the nearest target occurrence, or `-1` if the target never appears. Also support a streaming version that returns the newest index distance to the nearest target seen so far after each append. Implement: ```python def nearest_target_distances(chars: list[str], target: str) -> list[int]: pass def streaming_nearest_target(chars: list[str], target: str) -> list[int]: pass ```

Quick Answer: Practice a Snowflake coding interview problem focused on find the nearest target character and support streaming updates. The prompt emphasizes edge cases, clean implementation, and verifiable test behavior without revealing the solution.

Return distance from each character to the nearest occurrence of a target character.

Examples

Input: {"chars":["a","b","c","b"],"target":"b"}

Expected Output: [1,0,1,0]

Explanation: Targets on both sides.

Input: {"chars":[],"target":"x"}

Expected Output: []

Explanation: Empty.

Last updated: Jul 4, 2026

Loading coding console...

PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.

Related Coding Questions

  • Sort an RGB Record Collection In Place - Snowflake (medium)
  • Implement a JSON Parser - Snowflake (hard)
  • Determine Whether an Undirected Graph Is 3-Colorable - Snowflake (medium)
  • Answer Repeated Lookup Queries Efficiently - Snowflake (medium)