设计
文章平均质量分 79
memcpy0
希望探索文理结合的自由之路。
展开
-
LeetCode 2353. 设计食物评分系统【设计,哈希表,有序集合;堆+懒删除】1781
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2024-01-07 20:36:16 · 1502 阅读 · 0 评论 -
LeetCode 341. 扁平化嵌套列表迭代器【设计,迭代器,DFS或栈】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-20 16:29:55 · 183 阅读 · 1 评论 -
LeetCode 1670. 设计前中后队列【设计,双端队列,数据流】1610
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-16 09:24:12 · 74 阅读 · 0 评论 -
LeetCode 2034. 股票价格波动【设计,哈希表,有序映射】1831
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。。原创 2023-10-09 11:08:23 · 113 阅读 · 0 评论 -
LeetCode 284. Peeking Iterator【设计/迭代器/数组】中等
本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库。在这一仓库中,你不仅可以看到LeetCode原题链接、题解代码、题解文章链接、同类.原创 2021-11-11 16:48:50 · 231 阅读 · 1 评论 -
LeetCode C++ 1865. Finding Pairs With a Certain Sum【Design/Hash Table】中等
You are given two integer arrays nums1 and nums2. You are tasked to implement a data structure that supports queries of two types: Add a positive integer to an element of a given index in the array nums2. Count the number of pairs (i, j) such that nums1原创 2021-05-21 15:32:48 · 245 阅读 · 0 评论 -
LeetCode C++ 1845. Seat Reservation Manager【Heap/Design】中等
Design a system that manages the reservation state of n seats that are numbered from 1 to n.Implement the SeatManager class: SeatManager(int n) Initializes a SeatManager object that will manage n seats numbered from 1 to n. All seats are initially avail原创 2021-05-04 01:49:38 · 209 阅读 · 0 评论 -
LeetCode C++ 208. Implement Trie (Prefix Tree)【Trie/Design】中等
A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker.Implement the Trie class原创 2021-04-14 00:56:06 · 151 阅读 · 0 评论 -
LeetCode C++ 面试题 16.25. LRU Cache LCCI【设计/哈希表/链表】中等
Design and build a “least recently used” cache, which evicts the least recently used item. The cache should map from keys to values (allowing you to insert and retrieve a value associated with a particular key) and be initialized with a max size. When it原创 2021-04-13 19:36:24 · 190 阅读 · 0 评论 -
LeetCode C++ 1603. Design Parking System【Design】简单
Design a parking system for a parking lot. The parking lot has three kinds of parking spaces: big, medium, and small, with a fixed number of slots for each size.Implement the ParkingSystem class: ParkingSystem(int big, int medium, int small) Initializes原创 2021-03-19 18:06:34 · 217 阅读 · 0 评论 -
LeetCode C++ 706. Design HashMap【Design/Hash Table】简单
Design a HashMap without using any built-in hash table libraries.Implement the MyHashMap class: MyHashMap() initializes the object with an empty map. void put(int key, int value) inserts a (key, value) pair into the HashMap. If the key already exists i原创 2021-03-14 21:32:02 · 209 阅读 · 0 评论 -
LeetCode C++ 703. Kth Largest Element in a Stream【Heap/Design】简单
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.Implement KthLargest class: KthLargest(int k, int[] nums) Initializes the object wi原创 2020-12-25 21:43:49 · 204 阅读 · 0 评论 -
LeetCode C++ 157. Read N Characters Given Read4【String/Design】简单
Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters.Method read4: The API read4 reads 4 consecutive characters from the file, then writes those characters into the buffer a原创 2020-12-20 18:55:38 · 179 阅读 · 0 评论 -
LeetCode C++ 面试题 03.06. Animal Shelter LCCI【Queue/Design】简单
enqueue method has a animal parameter, animal[0] represents the number of the animal, animal[1] represents the type of the animal, 0 for cat and 1 for dog.dequeue* method returns [animal number, animal type], if there’s no animal that can be adopted, retu原创 2020-11-17 00:32:53 · 226 阅读 · 1 评论 -
LeetCode C++ 面试题 03.04. Implement Queue using Stacks LCCI【Stack/Queue/Design】简单
Implement a MyQueue class which implements a queue using two stacks.Example:MyQueue queue = new MyQueue();queue.push(1);queue.push(2);queue.peek(); // return 1queue.pop(); // return 1queue.empty(); // return falseNotes:You must use only stan原创 2020-11-13 01:03:27 · 148 阅读 · 0 评论 -
LeetCode C++ 460. LFU Cache【Design/Hash Table/Double LinkedList】困难
Design and implement a data structure for Least Frequently Used (LFU) cache .Implement the LFUCache class:LFUCache(int capacity) Initializes the object with the capacity of the data structure.int get(int key) Gets the value of the key if the key exists原创 2020-10-23 16:11:12 · 216 阅读 · 0 评论 -
LeetCode 146. LRU Cache【设计,哈希表,双向链表】中等
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache .Implement the LRUCache class:LRUCache(int capacity) Initialize the LRU cache with positive size capacity .int get(int key) Return the value of the key if the key原创 2020-10-20 22:41:34 · 302 阅读 · 1 评论 -
LeetCode C++ 面试题 03.02. Min Stack LCCI【Stack/Design】简单
How would you design a stack which, in addition to push and pop, has a function min which returns the minimum element? Push, pop and min should all operate in O(1) time.Example:MinStack minStack = new MinStack();minStack.push(-2);minStack.push(0);minS原创 2020-10-19 22:42:56 · 173 阅读 · 0 评论 -
LeetCode C++ 641. Design Circular Deque【设计/队列】中等
Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations:MyCircularDeque(k) : Constructor, set the size of the deque to be k .insertFront() : Adds an item at the front of Deque. Retur原创 2020-10-02 17:10:20 · 158 阅读 · 0 评论 -
LeetCode C++ 622. Design Circular Queue【设计/循环队列】中等
Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circl原创 2020-10-02 17:00:49 · 151 阅读 · 0 评论 -
LeetCode C++ 173. Binary Search Tree Iterator【二叉搜索树/栈/设计】中等
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST.Example:BSTIterator iterator = new BSTIterator(root);iterator.next();原创 2020-09-22 18:29:31 · 220 阅读 · 0 评论