An AI model's output arrives as a stream of text chunks: an ordered list of strings, stream. The stream contains a stop token, the literal string "<END>", marking where the meaningful output ends. In this part, the stop token always appears fully inside a single chunk.
Return only the chunks that come before the stop token, following these rules:
Constraints:
stream.size() ≤ stream.get(i).length() ≤ Constraints:
<END> (length 5); matching is case-sensitive.stream.size() ≤ stream.get(i).length() ≤ Example 1:
Input: stream = ["hello", "how are you<END>", "HAPPY"] Output: ["hello", "how are you"] Explanation:
- The first chunk "hello" contains no stop token, so it is emitted unchanged.
- The second chunk "how are you<END>" contains the stop token <END>; only the text before it, "how are you", is emitted, and everything from <END> onward is discarded.
- The third chunk "HAPPY" comes after the stop token and is dropped entirely.
Example 2:
Input: stream = ["", "keep", "<END>drop", "later"] Output: ["", "keep"]
Example 3:
Input: stream = ["alpha", "", "beta"] Output: ["alpha", "", "beta"]