Leetcode-cn.com 2022-03-16
🔴 432.all-oone-data-structure
🏷️ Tags
#design #hash_table #linked_list #doubly_linked_list
Description
请你设计一个用于存储字符串计数的数据结构,并能够返回计数最小和最大的字符串。
实现
Example
🔴 432.all-oone-data-structure
🏷️ Tags
#design #hash_table #linked_list #doubly_linked_list
Description
请你设计一个用于存储字符串计数的数据结构,并能够返回计数最小和最大的字符串。
实现
AllOne 类:AllOne() 初始化数据结构的对象。inc(String key) 字符串 key 的计数增加 1 。如果数据结构中尚不存在 key ,那么插入计数为 1 的 key 。dec(String key) 字符串 key 的计数减少 1 。如果 key 的计数在减少后为 0 ,那么需要将这个 key 从数据结构中删除。测试用例保证:在减少计数前,key 存在于数据结构中。getMaxKey() 返回任意一个计数最大的字符串。如果没有元素存在,返回一个空字符串 "" 。getMinKey() 返回任意一个计数最小的字符串。如果没有元素存在,返回一个空字符串 "" 。Example
输入
["AllOne", "inc", "inc", "getMaxKey", "getMinKey", "inc", "getMaxKey", "getMinKey"]
[[], ["hello"], ["hello"], [], [], ["leet"], [], []]
输出
[null, null, null, "hello", "hello", null, "hello", "leet"]
解释
AllOne allOne = new AllOne();
allOne.inc("hello");
allOne.inc("hello");
allOne.getMaxKey(); // 返回 "hello"
allOne.getMinKey(); // 返回 "hello"
allOne.inc("leet");
allOne.getMaxKey(); // 返回 "hello"
allOne.getMinKey(); // 返回 "leet"
1472.design-browser-history.pdf
62.8 KB
leetcode.com 2023-03-18
🟡1472.design-browser-history
🏷️ Tags
#array #linked_list #stack #design #doubly_linked_list #data_stream
🟡1472.design-browser-history
🏷️ Tags
#array #linked_list #stack #design #doubly_linked_list #data_stream
leetcode.cn 2025-02-27
🔴2296.design-a-text-editor
🏷️ Tags
#stack #design #linked_list #string #doubly_linked_list #simulation
🔴2296.design-a-text-editor
🏷️ Tags
#stack #design #linked_list #string #doubly_linked_list #simulation
Telegraph
design-a-text-editor
请你设计一个带光标的文本编辑器,它可以实现以下功能: