You are given an ordered stream of messages where each message is identified by a unique, non-negative offset starting at 0. In a multi-threaded environment, the messages may be processed out of order. However, when committing (acknowledging) a message, the system requires that all messages with lower offsets have already been processed. Below is a detailed description of the commit rules:
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected