Lock escalation threshold

Write codeMedium25 minMicrosoft and Oracle style

Your task

A database escalates row locks to a table lock to save memory. A transaction acquires row locks over time. acquisitions is a list of row ids (with possible repeats) acquired in order. The lock manager escalates to a single table-level lock the first moment the number of DISTINCT rows held reaches a threshold. Once escalated, all further row acquisitions are absorbed by the table lock (no new row locks tracked). Re-acquiring an already-held row before escalation does not increase the distinct count. Return the 1-based index in 'acquisitions' at which escalation is triggered, or -1 if escalation never happens.

Examples

lock_escalation_point(acquisitions: list[int], threshold: int) -> int
Example 1
Inputlock_escalation_point([1, 2, 2, 3, 4], 3)
Output4