A session window groups one user's activity until that user remains inactive for a configured gap. Different users maintain independent sessions even when their events are interleaved.
Design a SessionWindowAssigner class:
SessionWindowAssigner() creates a stateless assigner.int[] assign(String[] users, int[] timestamps, int inactivityGap) returns the session number for every event.
Events are in nondecreasing timestamp order. Each user's first event belongs to session 1. A later event starts the next session for that user when its timestamp minus that user's immediately previous timestamp is greater than or equal to inactivityGap. Otherwise it remains in the current session. Return results in input order.
Example 1:
Example 2:
Constraints
0 <= users.length <= 10^4users.length == timestamps.length1 <= users[i].length <= 300 <= timestamps[i] <= 10^9- Timestamps are nondecreasing.
1 <= inactivityGap <= 10^9- At most
100 calls are made to assign.