Bounded buffer producer consumer
Your task
Simulate a single bounded buffer of capacity k shared by producers and consumers. You are given an ops list of strings, each either "P" (a producer tries to enqueue one item) or "C" (a consumer tries to dequeue one item). The buffer starts empty. A "P" succeeds only if the buffer is not full; a "C" succeeds only if the buffer is not empty. Operations that would block are dropped (skipped) rather than waiting. Process ops left to right and return a pair [final_size, completed] where final_size is the number of items left in the buffer and completed is the count of operations that succeeded.
Examples
simulate_buffer(k: int, ops: list[str]) -> list[int]Example 1
Input
simulate_buffer(2, ["P", "P", "P", "C", "C", "C"])Output
[0, 4]