Q1. Message Storage
A messaging system receives messages at different timestamps.
Each message is stored for 10 seconds after it arrives. At any timestamp "t", all messages whose timestamp is more than 10 seconds older than "t" are deleted.
For every incoming message, return the number of messages currently stored after adding that message and removing all expired messages.
Example
Input:
1 2 5 5 13 14
Output:
1 2 4 4 3 4
For example, when a message arrives at timestamp "13", messages from timestamps "1" and "2" have expired.
Constraints
- "1 <= N <= 10^6"
- "0 <= timestamp[i] <= 10^9"
- Timestamps are given in non-decreasing order.
- Multiple messages may have the same timestamp.
Return an array containing the number of stored messages after every incoming message.