Back to problems

Streaming Stop Token

Algorithm · Microsoft · Hard

You are given a sequence of text pieces, stream, which represents the output tokens from an AI model. The token " " serves as a delimiter indicating the end of the useful content. For this problem, you can assume that the entire stop token will always appear inside a single chunk, never split across chunks. Your task is to extract all chunks that appear before the stop token, subject to the following requirements: Each chunk from the input can yield at most one output chunk;…

Checking your access…