Z57
All O`one Data Structure
Problem Statement & Objective
Design a data structure to store the strings' count with the ability to return the strings with minimum and maximum counts in O(1) time.
Function Signature (Python)
all_oone_data_structure(operations: list) -> listInput & Output Contract
Output Rule:İşlem sonuçları listesi (None veya string).
System Constraints
1 <= islemler.length <= 5 * 10^4
1 <= key.length <= 10
dec çağrıldığında key kesinlikle veri yapısında mevcutturExample Execution Walkthrough
islemler = [['inc', 'hello'], ['inc', 'hello'], ['getMaxKey'], ['getMinKey'], ['inc', 'kodla'], ['getMaxKey'], ['getMinKey']]
'hello': 2
getMaxKey -> 'hello'
getMinKey -> 'hello'
'kodla': 1
getMaxKey -> 'hello'
getMinKey -> 'kodla'
Cevap: [None, None, 'hello', 'hello', None, 'hello', 'kodla']Example Test Scenarios (3)
Example 1: Basic Flow
Input:
[[["inc","hello"],["inc","hello"],["getMaxKey"],["getMinKey"],["inc","kodla"],["getMaxKey"],["getMinKey"]]]Expected Output:
[null,null,"hello","hello",null,"hello","kodla"]Example 2: Boş Durum
Input:
[[["getMaxKey"],["getMinKey"]]]Expected Output:
["",""]Example 3: Silme Sonrası Boş
Input:
[[["inc","a"],["dec","a"],["getMaxKey"]]]Expected Output:
[null,null,""]