Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates several LeetCode solution READMEs to add/expand “Solution 1” explanations (algorithm name + short rationale) and improves a few formatting inconsistencies in examples.
Changes:
- Add named solution headings (e.g., “Array”, “Mathematics”, “Greedy + Priority Queue”) and richer algorithm explanations.
- Expand step-by-step descriptions and complexity notes across multiple problems.
- Minor formatting cleanup in example blocks (whitespace consistency).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| solution/0600-0699/0641.Design Circular Deque/README_EN.md | Adds an “Array” approach explanation and complexity notes |
| solution/0600-0699/0641.Design Circular Deque/README.md | Expands the Chinese explanation for the array-based circular deque |
| solution/0600-0699/0640.Solve the Equation/README_EN.md | Adds a “Mathematics” solution summary and related-problem link |
| solution/0600-0699/0630.Course Schedule III/README_EN.md | Cleans example formatting and adds greedy + max-heap explanation |
| solution/0600-0699/0609.Find Duplicate File in System/README_EN.md | Adds “Hash Table” solution explanation and complexity |
| solution/0600-0699/0609.Find Duplicate File in System/README.md | Expands Chinese hash-table explanation and complexity wording |
| solution/0600-0699/0602.Friend Requests II Who Has the Most Friends/README_EN.md | Fixes example whitespace and adds “Union All + Group By” explanation |
| solution/0600-0699/0602.Friend Requests II Who Has the Most Friends/README.md | Adds a short Chinese explanation for merge + group approach |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| When $\textit{insertFront}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position forward (using modular arithmetic for circular wrapping), insert the new element at $\textit{front}$, and increment $\textit{size}$ by 1. | ||
|
|
||
| When $\textit{insertLast}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we compute the insertion position (using $\textit{front}$ and $\textit{size}$), insert the new element there, and increment $\textit{size}$ by 1. | ||
|
|
||
| When $\textit{deleteFront}$ is called, we first check if the queue is empty; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position backward (using modular arithmetic for circular wrapping) and decrement $\textit{size}$ by 1. |
There was a problem hiding this comment.
The direction of the front pointer updates appears reversed for a typical circular deque where front points to the current front element. Usually, insertFront decrements front (wrap-around), while deleteFront increments front. Please adjust the wording (or add an explicit formula like front = (front - 1 + capacity) % capacity / front = (front + 1) % capacity) so the explanation matches the actual index movement semantics.
| When $\textit{insertFront}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position forward (using modular arithmetic for circular wrapping), insert the new element at $\textit{front}$, and increment $\textit{size}$ by 1. | |
| When $\textit{insertLast}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we compute the insertion position (using $\textit{front}$ and $\textit{size}$), insert the new element there, and increment $\textit{size}$ by 1. | |
| When $\textit{deleteFront}$ is called, we first check if the queue is empty; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position backward (using modular arithmetic for circular wrapping) and decrement $\textit{size}$ by 1. | |
| When $\textit{insertFront}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position backward (for example, $\textit{front} = (\textit{front} - 1 + \textit{capacity}) \bmod \textit{capacity}$), insert the new element at $\textit{front}$, and increment $\textit{size}$ by 1. | |
| When $\textit{insertLast}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we compute the insertion position (using $\textit{front}$ and $\textit{size}$), insert the new element there, and increment $\textit{size}$ by 1. | |
| When $\textit{deleteFront}$ is called, we first check if the queue is empty; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position forward (for example, $\textit{front} = (\textit{front} + 1) \bmod \textit{capacity}$) and decrement $\textit{size}$ by 1. |
| When $\textit{insertFront}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position forward (using modular arithmetic for circular wrapping), insert the new element at $\textit{front}$, and increment $\textit{size}$ by 1. | ||
|
|
||
| When $\textit{insertLast}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we compute the insertion position (using $\textit{front}$ and $\textit{size}$), insert the new element there, and increment $\textit{size}$ by 1. | ||
|
|
||
| When $\textit{deleteFront}$ is called, we first check if the queue is empty; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position backward (using modular arithmetic for circular wrapping) and decrement $\textit{size}$ by 1. |
There was a problem hiding this comment.
The direction of the front pointer updates appears reversed for a typical circular deque where front points to the current front element. Usually, insertFront decrements front (wrap-around), while deleteFront increments front. Please adjust the wording (or add an explicit formula like front = (front - 1 + capacity) % capacity / front = (front + 1) % capacity) so the explanation matches the actual index movement semantics.
| When $\textit{insertFront}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position forward (using modular arithmetic for circular wrapping), insert the new element at $\textit{front}$, and increment $\textit{size}$ by 1. | |
| When $\textit{insertLast}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we compute the insertion position (using $\textit{front}$ and $\textit{size}$), insert the new element there, and increment $\textit{size}$ by 1. | |
| When $\textit{deleteFront}$ is called, we first check if the queue is empty; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position backward (using modular arithmetic for circular wrapping) and decrement $\textit{size}$ by 1. | |
| When $\textit{insertFront}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position backward (e.g., $\textit{front} = (\textit{front} - 1 + \textit{capacity}) \bmod \textit{capacity}$), insert the new element at $\textit{front}$, and increment $\textit{size}$ by 1. | |
| When $\textit{insertLast}$ is called, we first check if the queue is full; if so, return $\text{false}$. Otherwise, we compute the insertion position (using $\textit{front}$ and $\textit{size}$), insert the new element there, and increment $\textit{size}$ by 1. | |
| When $\textit{deleteFront}$ is called, we first check if the queue is empty; if so, return $\text{false}$. Otherwise, we move $\textit{front}$ one position forward (e.g., $\textit{front} = (\textit{front} + 1) \bmod \textit{capacity}$) and decrement $\textit{size}$ by 1. |
| 调用 $\textit{insertFront}$ 时,首先检查队列是否已满,如果已满则返回 $\text{false}$。如果队列不为空,则将 $\textit{front}$ 向前移动一个位置(使用模运算实现循环),然后将新元素插入到 $\textit{front}$ 位置,并将 $\textit{size}$ 加 1。 | ||
|
|
||
| - front:队头元素的下标 | ||
| - size:队列中元素的个数 | ||
| - capacity:队列的容量 | ||
| - q:循环数组,存储队列中的元素 | ||
| 调用 $\textit{insertLast}$ 时,首先检查队列是否已满,如果已满则返回 $\text{false}$。如果队列不为空,则计算新元素应该插入的位置(使用 $\textit{front}$ 和 $\textit{size}$ 计算),将新元素插入到该位置,并将 $\textit{size}$ 加 1。 | ||
|
|
||
| 时间复杂度 $O(1)$,空间复杂度 $O(k)$。其中 $k$ 是队列的容量。 | ||
| 调用 $\textit{deleteFront}$ 时,首先检查队列是否为空,如果为空则返回 $\text{false}$。如果队列不为空,则将 $\textit{front}$ 向后移动一个位置(使用模运算实现循环),并将 $\textit{size}$ 减 1。 |
There was a problem hiding this comment.
insertFront / insertLast 的描述里使用了“如果队列不为空”,这与前面的“是否已满”判断不一致(队列为空时也应允许插入)。建议将该条件改为“否则”(即不满即可插入),并同时用明确的下标更新公式说明 front 的移动方向(避免与实现语义产生冲突)。
No description provided.