-
Docker 101: When to Use Docker Networking
•
When to Use Docker Networking (Docker 的网络功能) Introduction / 介绍 Docker’s networking capabilities are a crucial feature when deploying multiple containerized applications that need to communicate with each other. Understanding when and how to use Docker’s networking features ensures that your applications are connected correctly and securely, especially when deploying…
-
Docker 101: Understanding the `localhost` Issue in Docker Containers
•
Understanding the localhost Issue in Docker Containers Context English: When running multiple services in Docker containers, it’s common to have them communicate with each other over a network. However, a common pitfall occurs when using localhost to reference services, which can lead to connectivity issues between containers. Chinese: 在 Docker…
-
Algorithms 101: Deque Implementation Using Fixed Array
•
Deque Implementation Using Fixed Array (双端队列用固定数组的实现) Implementing a deque using a fixed-size array is another efficient method that provides constant-time access to elements and operations at both ends of the deque. This approach, however, requires handling the circular nature of the deque when the array is full or when operations…
-
Algorithms 101: Deque Implementation Using Doubly Linked List
•
Deque Implementation Using Doubly Linked List (双端队列用双链表的实现) A deque can be efficiently implemented using a doubly linked list. This approach allows constant-time insertions and deletions at both the front and rear of the deque. In a doubly linked list, each node contains three parts: the data, a pointer to the…
-
Algorithms 101: Applications of Deque
•
Applications of Deque (双端队列的应用): 1. Sliding Window Problems (滑动窗口问题): In sliding window problems, deques are often used to efficiently find the maximum or minimum element within a window of elements as it slides across a list. The deque helps in maintaining a list of indices of elements in such a…
-
Algorithms 101: Introduction to Double-Ended Queue
•
Introduction to Double-Ended Queue (双端队列的介绍) A Double-Ended Queue (Deque) is a versatile data structure that allows elements to be inserted and removed from both ends, unlike a standard queue, where operations are restricted to one end for insertion (enqueue) and the other for removal (dequeue). This flexibility makes deques suitable…
-
LeetCode: 278 First Bad Version
•
LeetCode: 278 First Bad Version You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also…
-
LeetCode: 232 Implement Queue using Stacks
•
LeetCode: 232 Implement Queue using Stacks Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, pop, peek, empty). push(x) — Pushes element x to the back of the queue. pop() — Removes the element…
-
LeetCode: 155 Min Stack
•
LeetCode: 155 Min Stack Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) — Pushes element x onto the stack. pop() — Removes the element on the top of the stack. top() — Gets the top element. getMin() — Retrieves the minimum…
-
Algorithms 101: How Python Implements a Queue Behind the Scenes
•
How Python Implements a Queue Behind the Scenes In Python, a queue is not a built-in data structure with a dedicated implementation like in some other programming languages. Instead, Python offers several ways to implement a queue, with the most common being through the collections.deque (double-ended queue) class and the…