krahets 11 months ago
parent ef0f9dba2e
commit eae73fc284

2
.gitignore vendored

@ -5,5 +5,3 @@
*.png *.png
*.jpg *.jpg
*.gif *.gif
docs-en

@ -0,0 +1,26 @@
---
comments: true
icon: material/timer-sand
---
# 第 2 章   Complexity Analysis
<div class="center-table" markdown>
![complexity_analysis](../assets/covers/chapter_complexity_analysis.jpg){ width="600" }{ class="cover-image" }
</div>
!!! abstract
Complexity analysis is like a space-time guide in the vast universe of algorithms.
It leads us to explore deeply in the dimensions of time and space, in search of more elegant solutions.
## 本章内容
- [2.1 &nbsp; Evaluating Algorithm Efficiency](https://www.hello-algo.com/chapter_computational_complexity/performance_evaluation/)
- [2.2 &nbsp; Iteration and Recursion](https://www.hello-algo.com/chapter_computational_complexity/iteration_and_recursion/)
- [2.3 &nbsp; Time Complexity](https://www.hello-algo.com/chapter_computational_complexity/time_complexity/)
- [2.4 &nbsp; Space Complexity](https://www.hello-algo.com/chapter_computational_complexity/space_complexity/)
- [2.5 &nbsp; Summary](https://www.hello-algo.com/chapter_computational_complexity/summary/)

@ -0,0 +1,53 @@
---
comments: true
---
# 2.1 &nbsp; Evaluation Of Algorithm Efficiency
In algorithm design, we aim to achieve two goals in succession:
1. **Finding a Solution to the Problem**: The algorithm needs to reliably find the correct solution within the specified input range.
2. **Seeking the Optimal Solution**: There may be multiple ways to solve the same problem, and our goal is to find the most efficient algorithm possible.
In other words, once the ability to solve the problem is established, the efficiency of the algorithm emerges as the main benchmark for assessing its quality, which includes the following two aspects.
- **Time Efficiency**: The speed at which an algorithm runs.
- **Space Efficiency**: The amount of memory space the algorithm consumes.
In short, our goal is to design data structures and algorithms that are both "fast and economical". Effectively evaluating algorithm efficiency is crucial, as it allows for the comparison of different algorithms and guides the design and optimization process.
There are mainly two approaches for assessing efficiency: practical testing and theoretical estimation.
## 2.1.1 &nbsp; Practical Testing
Let's consider a scenario where we have two algorithms, `A` and `B`, both capable of solving the same problem. To compare their efficiency, the most direct method is to use a computer to run both algorithms while monitoring and recording their execution time and memory usage. This approach provides a realistic assessment of their performance, but it also has significant limitations.
On one hand, it's challenging to eliminate the interference of the test environment. Hardware configurations can significantly affect the performance of algorithms. For instance, on one computer, Algorithm `A` might run faster than Algorithm `B`, but the results could be the opposite on another computer with different specifications. This means we would need to conduct tests on a variety of machines and calculate an average efficiency, which is impractical.
Furthermore, conducting comprehensive tests is resource-intensive. The efficiency of algorithms can vary with different volumes of input data. For example, with smaller data sets, Algorithm A might run faster than Algorithm B; however, this could change with larger data sets. Therefore, to reach a convincing conclusion, it's necessary to test a range of data sizes, which requires excessive computational resources.
## 2.1.2 &nbsp; Theoretical Estimation
Given the significant limitations of practical testing, we can consider assessing algorithm efficiency solely through calculations. This method of estimation is known as 'asymptotic complexity analysis,' often simply referred to as 'complexity analysis.
Complexity analysis illustrates the relationship between the time (and space) resources required by an algorithm and the size of its input data. **It describes the growing trend in the time and space required for the execution of an algorithm as the size of the input data increases**. This definition might sound a bit complex, so let's break it down into three key points for easier understanding.
- In complexity analysis, 'time and space' directly relate to 'time complexity' and 'space complexity,' respectively.
- The statement "as the size of the input data increases" highlights that complexity analysis examines the interplay between the size of the input data and the algorithm's efficiency.
- Lastly, the phrase "the growing trend in time and space required" emphasizes that the focus of complexity analysis is not on the specific values of running time or space occupied, but on the rate at which these requirements increase with larger input sizes.
**Complexity analysis overcomes the drawbacks of practical testing methods in two key ways:**.
- It is independent of the testing environment, meaning the analysis results are applicable across all operating platforms.
- It effectively demonstrates the efficiency of algorithms with varying data volumes, particularly highlighting performance in large-scale data scenarios.
!!! tip
If you're still finding the concept of complexity confusing, don't worry. We will cover it in more detail in the subsequent chapters.
Complexity analysis provides us with a 'ruler' for evaluating the efficiency of algorithms, enabling us to measure the time and space resources required to execute a given algorithm and to compare the efficiency of different algorithms.
Complexity is a mathematical concept that might seem abstract and somewhat challenging for beginners. From this perspective, introducing complexity analysis at the very beginning may not be the most suitable approach. However, when discussing the characteristics of a particular data structure or algorithm, analyzing its operational speed and space usage is often inevitable.
Therefore, it is recommended that before diving deeply into data structures and algorithms, **one should first gain a basic understanding of complexity analysis. This foundational knowledge will facilitate the complexity analysis of simple algorithms.**

File diff suppressed because it is too large Load Diff

@ -0,0 +1,53 @@
---
comments: true
---
# 2.5 &nbsp; Summary
### 1. &nbsp; Highlights
**Evaluation of Algorithm Efficiency**
- Time and space efficiency are the two leading evaluation indicators to measure an algorithm.
- We can evaluate the efficiency of an algorithm through real-world testing. Still, it isn't easy to eliminate the side effects from the testing environment, and it consumes a lot of computational resources.
- Complexity analysis overcomes the drawbacks of real-world testing. The analysis results can apply to all operating platforms and reveal the algorithm's efficiency under variant data scales.
**Time Complexity**
- Time complexity is used to measure the trend of algorithm running time as the data size grows., which can effectively evaluate the algorithm's efficiency. However, it may fail in some cases, such as when the input volume is small or the time complexities are similar, making it difficult to precisely compare the efficiency of algorithms.
- The worst time complexity is denoted by big $O$ notation, which corresponds to the asymptotic upper bound of the function, reflecting the growth rate in the number of operations $T(n)$ as $n$ tends to positive infinity.
- The estimation of time complexity involves two steps: first, counting the number of operations, and then determining the asymptotic upper bound.
- Common time complexities, from lowest to highest, are $O(1)$, $O(\log n)$, $O(n)$, $O(n \log n)$, $O(n^2)$, $O(2^n)$, and $O(n!)$.
- The time complexity of certain algorithms is not fixed and depends on the distribution of the input data. The time complexity can be categorized into worst-case, best-case, and average. The best-case time complexity is rarely used because the input data must meet strict conditions to achieve the best-case.
- The average time complexity reflects the efficiency of an algorithm with random data inputs, which is closest to the performance of algorithms in real-world scenarios. Calculating the average time complexity requires statistical analysis of input data and a synthesized mathematical expectation.
**Space Complexity**
- Space complexity serves a similar purpose to time complexity and is used to measure the trend of space occupied by an algorithm as the data volume increases.
- The memory space associated with the operation of an algorithm can be categorized into input space, temporary space, and output space. Normally, the input space is not considered when determining space complexity. The temporary space can be classified into instruction space, data space, and stack frame space, and the stack frame space usually only affects the space complexity for recursion functions.
- We mainly focus on the worst-case space complexity, which refers to the measurement of an algorithm's space usage when given the worst-case input data and during the worst-case execution scenario.
- Common space complexities are $O(1)$, $O(\log n)$, $O(n)$, $O(n^2)$ and $O(2^n)$ from lowest to highest.
### 2. &nbsp; Q & A
!!! question "Is the space complexity of tail recursion $O(1)$?"
Theoretically, the space complexity of a tail recursion function can be optimized to $O(1)$. However, most programming languages (e.g., Java, Python, C++, Go, C#, etc.) do not support auto-optimization for tail recursion, so the space complexity is usually considered as $O(n)$.
!!! question "What is the difference between the terms function and method?"
A *function* can be executed independently, and all arguments are passed explicitly. A *method* is associated with an object and is implicitly passed to the object that calls it, allowing it to operate on the data contained within an instance of a class.
Let's illustrate with a few common programming languages.
- C is a procedural programming language without object-oriented concepts, so it has only functions. However, we can simulate object-oriented programming by creating structures (struct), and the functions associated with structures are equivalent to methods in other languages.
- Java and C# are object-oriented programming languages, and blocks of code (methods) are typically part of a class. Static methods behave like a function because it is bound to the class and cannot access specific instance variables.
- Both C++ and Python support both procedural programming (functions) and object-oriented programming (methods).
!!! question "Does the figure "Common Types of Space Complexity" reflect the absolute size of the occupied space?"
No, that figure shows the space complexity, which reflects the growth trend, not the absolute size of the space occupied.
For example, if you take $n = 8$ , the values of each curve do not align with the function because each curve contains a constant term used to compress the range of values to a visually comfortable range.
In practice, since we usually don't know each method's "constant term" complexity, it is generally impossible to choose the optimal solution for $n = 8$ based on complexity alone. But it's easier to choose for $n = 8^5$ as the growth trend is already dominant.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,49 @@
# Classification Of Data Structures
Common data structures include arrays, linked lists, stacks, queues, hash tables, trees, heaps, and graphs. They can be divided into two categories: logical structure and physical structure.
## Logical Structures: Linear And Non-linear
**Logical structures reveal logical relationships between data elements**. In arrays and linked lists, data are arranged in sequential order, reflecting the linear relationship between data; while in trees, data are arranged hierarchically from the top down, showing the derived relationship between ancestors and descendants; and graphs are composed of nodes and edges, reflecting the complex network relationship.
As shown in the figure below, logical structures can further be divided into "linear data structure" and "non-linear data structure". Linear data structures are more intuitive, meaning that the data are arranged linearly in terms of logical relationships; non-linear data structures, on the other hand, are arranged non-linearly.
- **Linear data structures**: arrays, linked lists, stacks, queues, hash tables.
- **Nonlinear data structures**: trees, heaps, graphs, hash tables.
![Linear and nonlinear data structures](classification_of_data_structure.assets/classification_logic_structure.png)
Non-linear data structures can be further divided into tree and graph structures.
- **Linear structures**: arrays, linked lists, queues, stacks, hash tables, with one-to-one sequential relationship between elements.
- **Tree structure**: tree, heap, hash table, with one-to-many relationship between elements.
- **Graph**: graph with many-to-many relationship between elements.
## Physical Structure: Continuous vs. Dispersed
**When an algorithm is running, the data being processed is stored in memory**. The figure below shows a computer memory module where each black square represents a memory space. We can think of the memory as a giant Excel sheet in which each cell can store data of a certain size.
**The system accesses the data at the target location by means of a memory address**. As shown in the figure below, the computer assigns a unique identifier to each cell in the table according to specific rules, ensuring that each memory space has a unique memory address. With these addresses, the program can access the data in memory.
![memory_strip, memory_space, memory_address](classification_of_data_structure.assets/computer_memory_location.png)
!!! tip
It is worth noting that comparing memory to the Excel sheet is a simplified analogy. The actual memory working mechanism is more complicated, involving the concepts of address, space, memory management, cache mechanism, virtual and physical memory.
Memory is a shared resource for all programs, and when a block of memory is occupied by one program, it cannot be used by other programs at the same time. **Therefore, considering memory resources is crucial in designing data structures and algorithms**. For example, the algorithm's peak memory usage should not exceed the remaining free memory of the system; if there is a lack of contiguous memory blocks, then the data structure chosen must be able to be stored in non-contiguous memory blocks.
As shown in the figure below, **Physical structure reflects the way data is stored in computer memory and it can be divided into consecutive space storage (arrays) and distributed space storage (linked lists)**. The physical structure determines how data is accessed, updated, added, deleted, etc. Logical and physical structure complement each other in terms of time efficiency and space efficiency.
![continuous vs. decentralized spatial storage](classification_of_data_structure.assets/classification_phisical_structure.png)
**It is worth stating that all data structures are implemented based on arrays, linked lists, or a combination of the two**. For example, stacks and queues can be implemented using both arrays and linked lists; and implementations of hash tables may contain both arrays and linked lists.
- **Array-based structures**: stacks, queues, hash tables, trees, heaps, graphs, matrices, tensors (arrays of dimension $\geq 3$), and so on.
- **Linked list-based structures**: stacks, queues, hash tables, trees, heaps, graphs, etc.
Data structures based on arrays are also known as "static data structures", which means that such structures' length remains constant after initialization. In contrast, data structures based on linked lists are called "dynamic data structures", meaning that their length can be adjusted during program execution after initialization.
!!! tip
If you find it difficult to understand the physical structure, it is recommended that you read the next chapter, "Arrays and Linked Lists," before reviewing this section.

@ -0,0 +1,13 @@
# Data Structure
<div class="center-table" markdown>
![data structure](../assets/covers/chapter_data_structure.jpg){ width="600" }
</div>
!!! abstract
Data structures are like a solid and varied framework.
It provides a blueprint for the orderly organization of data upon which algorithms can come alive.

@ -0,0 +1,66 @@
---
comments: true
---
# 1.1 &nbsp; Algorithms Are Everywhere
When we hear the word "algorithm", we naturally think of mathematics. However, many algorithms do not involve complex mathematics but rely more on basic logic, which is ubiquitous in our daily lives.
Before we formally discuss algorithms, an interesting fact is worth sharing: **you have already learned many algorithms unconsciously and have become accustomed to applying them in your daily life**. Below, I will give a few specific examples to prove this point.
**Example 1: Looking Up a Dictionary**. In a standard dictionary, each word corresponds to a phonetic transcription and the dictionary is organized alphabetically based on these transcriptions. Let's say we're looking for a word that begins with the letter $r$. This is typically done in the following way:
1. Open the dictionary around its midpoint and note the first letter on that page, assuming it to be $m$.
2. Given the sequence of words following the initial letter $m$, estimate where words starting with the letter $r$ might be located within the alphabetical order.
3. Iterate steps `1.` and `2.` until you find the page where the word begins with the letter $r$.
=== "<1>"
![Dictionary search step](algorithms_are_everywhere.assets/binary_search_dictionary_step1.png){ class="animation-figure" }
=== "<2>"
![binary_search_dictionary_step2](algorithms_are_everywhere.assets/binary_search_dictionary_step2.png){ class="animation-figure" }
=== "<3>"
![binary_search_dictionary_step3](algorithms_are_everywhere.assets/binary_search_dictionary_step3.png){ class="animation-figure" }
=== "<4>"
![binary_search_dictionary_step4](algorithms_are_everywhere.assets/binary_search_dictionary_step4.png){ class="animation-figure" }
=== "<5>"
![binary_search_dictionary_step5](algorithms_are_everywhere.assets/binary_search_dictionary_step5.png){ class="animation-figure" }
<p align="center"> Figure 1-1 &nbsp; Dictionary search step </p>
The skill of looking up a dictionary, essential for elementary school students, is actually the renowned binary search algorithm. Through the lens of data structures, we can view the dictionary as a sorted "array"; while from an algorithmic perspective, the series of operations in looking up a dictionary can be seen as "binary search".
**Example 2: Organizing Playing Cards**. When playing cards, we need to arrange the cards in ascending order each game, as shown in the following process.
1. Divide the playing cards into "ordered" and "unordered" parts, assuming initially that the leftmost card is already ordered.
2. Take out a card from the unordered part and insert it into the correct position in the ordered part; once completed, the leftmost two cards will be in an ordered sequence.
3. Continue the loop described in step `2.`, each iteration involving insertion of one card from the unordered segment into the ordered portion, until all cards are appropriately ordered.
![Playing cards sorting process](algorithms_are_everywhere.assets/playing_cards_sorting.png){ class="animation-figure" }
<p align="center"> Figure 1-2 &nbsp; Playing cards sorting process </p>
The above method of organizing playing cards is essentially the "insertion sort" algorithm, which is very efficient for small datasets. Many programming languages' sorting library functions include insertion sort.
**Example 3: Making Change**. Suppose we buy goods worth $69$ yuan at a supermarket and give the cashier $100$ yuan, then the cashier needs to give us $31$ yuan in change. They would naturally complete the thought process as shown below.
1. The options are currencies smaller than $31$, including $1$, $5$, $10$, and $20$.
2. Take out the largest $20$ from the options, leaving $31 - 20 = 11$.
3. Take out the largest $10$ from the remaining options, leaving $11 - 10 = 1$.
4. Take out the largest $1$ from the remaining options, leaving $1 - 1 = 0$.
5. Complete the change-making, with the solution being $20 + 10 + 1 = 31$.
![Change making process](algorithms_are_everywhere.assets/greedy_change.png){ class="animation-figure" }
<p align="center"> Figure 1-3 &nbsp; Change making process </p>
In the aforementioned steps, at each stage, we make the optimal choice (utilizing the highest denomination possible), ultimately deriving at a feasible change-making approach. From the perspective of data structures and algorithms, this approach is essentially a "greedy" algorithm.
From preparing a dish to traversing interstellar realms, virtually every problem-solving endeavor relies on algorithms. The emergence of computers enables us to store data structures in memory and write code to call CPUs and GPUs to execute algorithms. Consequently, we can transfer real-life predicaments to computers, efficiently addressing a myriad of complex issues.
!!! tip
If concepts such as data structures, algorithms, arrays, and binary search still seem somewhat obsecure, I encourage you to continue reading. This book will gently guide you into the realm of understanding data structures and algorithms.

@ -0,0 +1,24 @@
---
comments: true
icon: material/calculator-variant-outline
---
# 第 1 章 &nbsp; Introduction to Algorithms
<div class="center-table" markdown>
![A first look at the algorithm](../assets/covers/chapter_introduction.jpg){ width="600" }{ class="cover-image" }
</div>
!!! abstract
A graceful maiden dances, intertwined with the data, her skirt swaying to the melody of algorithms.
She invites you to a dance, follow her steps, and enter the world of algorithms full of logic and beauty.
## 本章内容
- [1.1 &nbsp; Algorithms Are Everywhere](https://www.hello-algo.com/chapter_introduction/algorithms_are_everywhere/)
- [1.2 &nbsp; What is Algorithms](https://www.hello-algo.com/chapter_introduction/what_is_dsa/)
- [1.3 &nbsp; Summary](https://www.hello-algo.com/chapter_introduction/summary/)

@ -0,0 +1,13 @@
---
comments: true
---
# 1.3 &nbsp; Summary
- Algorithms are ubiquitous in daily life and are not as inaccessible and complex as they might seem. In fact, we have already unconsciously learned many algorithms to solve various problems in life.
- The principle of looking up a word in a dictionary is consistent with the binary search algorithm. The binary search algorithm embodies the important algorithmic concept of divide and conquer.
- The process of organizing playing cards is very similar to the insertion sort algorithm. The insertion sort algorithm is suitable for sorting small datasets.
- The steps of making change in currency essentially follow the greedy algorithm, where each step involves making the best possible choice at the moment.
- An algorithm is a set of instructions or steps used to solve a specific problem within a finite amount of time, while a data structure is the way data is organized and stored in a computer.
- Data structures and algorithms are closely linked. Data structures are the foundation of algorithms, and algorithms are the stage to utilize the functions of data structures.
- We can liken data structures and algorithms to building blocks. The blocks represent data, the shape and connection method of the blocks represent data structures, and the steps of assembling the blocks correspond to algorithms.

@ -0,0 +1,65 @@
---
comments: true
---
# 1.2 &nbsp; What is an Algorithm
## 1.2.1 &nbsp; Definition of an Algorithm
An "algorithm" is a set of instructions or steps to solve a specific problem within a finite amount of time. It has the following characteristics:
- The problem is clearly defined, including unambiguous definitions of input and output.
- The algorithm is feasible, meaning it can be completed within a finite number of steps, time, and memory space.
- Each step has a definitive meaning. The output is consistently the same under the same inputs and conditions.
## 1.2.2 &nbsp; Definition of a Data Structure
A "data structure" is a way of organizing and storing data in a computer, with the following design goals:
- Minimize space occupancy to save computer memory.
- Make data operations as fast as possible, covering data access, addition, deletion, updating, etc.
- Provide concise data representation and logical information to enable efficient algorithm execution.
**Designing data structures is a balancing act, often requiring trade-offs**. If you want to improve in one aspect, you often need to compromise in another. Here are two examples:
- Compared to arrays, linked lists offer more convenience in data addition and deletion but sacrifice data access speed.
- Graphs, compared to linked lists, provide richer logical information but require more memory space.
## 1.2.3 &nbsp; Relationship Between Data Structures and Algorithms
As shown in the diagram below, data structures and algorithms are highly related and closely integrated, specifically in the following three aspects:
- Data structures are the foundation of algorithms. They provide structured data storage and methods for manipulating data for algorithms.
- Algorithms are the stage where data structures come into play. The data structure alone only stores data information; it is through the application of algorithms that specific problems can be solved.
- Algorithms can often be implemented based on different data structures, but their execution efficiency can vary greatly. Choosing the right data structure is key.
![Relationship between data structures and algorithms](what_is_dsa.assets/relationship_between_data_structure_and_algorithm.png){ class="animation-figure" }
<p align="center"> Figure 1-4 &nbsp; Relationship between data structures and algorithms </p>
Data structures and algorithms can be likened to a set of building blocks, as illustrated in the Figure 1-5 . A building block set includes numerous pieces, accompanied by detailed assembly instructions. Following these instructions step by step allows us to construct an intricate block model.
![Assembling blocks](what_is_dsa.assets/assembling_blocks.jpg){ class="animation-figure" }
<p align="center"> Figure 1-5 &nbsp; Assembling blocks </p>
The detailed correspondence between the two is shown in the Table 1-1 .
<p align="center"> Table 1-1 &nbsp; Comparing Data Structures and Algorithms to Building Blocks </p>
<div class="center-table" markdown>
| Data Structures and Algorithms | Building Blocks |
| ------------------------------ | --------------------------------------------------------------- |
| Input data | Unassembled blocks |
| Data structure | Organization of blocks, including shape, size, connections, etc |
| Algorithm | A series of steps to assemble the blocks into the desired shape |
| Output data | Completed Block model |
</div>
It's worth noting that data structures and algorithms are independent of programming languages. For this reason, this book is able to provide implementations in multiple programming languages.
!!! tip "Conventional Abbreviation"
In real-life discussions, we often refer to "Data Structures and Algorithms" simply as "Algorithms". For example, the well-known LeetCode algorithm problems actually test both data structure and algorithm knowledge.

@ -0,0 +1,51 @@
---
comments: true
---
# 0.1 &nbsp; The Book
The aim of this project is to create an open source, free, novice-friendly introductory tutorial on data structures and algorithms.
- Animated graphs are used throughout the book to structure the knowledge of data structures and algorithms in a way that is clear and easy to understand with a smooth learning curve.
- The source code of the algorithms can be run with a single click, supporting Java, C++, Python, Go, JS, TS, C#, Swift, Rust, Dart, Zig and other languages.
- Readers are encouraged to help each other and make progress in the chapter discussion forums, and questions and comments can usually be answered within two days.
## 0.1.1 &nbsp; Target Readers
If you are a beginner to algorithms, have never touched an algorithm before, or already have some experience brushing up on data structures and algorithms, and have a vague understanding of data structures and algorithms, repeatedly jumping sideways between what you can and can't do, then this book is just for you!
If you have already accumulated a certain amount of questions and are familiar with most of the question types, then this book can help you review and organize the algorithm knowledge system, and the repository source code can be used as a "brushing tool library" or "algorithm dictionary".
If you are an algorithm expert, we look forward to receiving your valuable suggestions or [participate in the creation together](https://www.hello-algo.com/chapter_appendix/contribution/).
!!! success "precondition"
You will need to have at least a basic knowledge of programming in any language and be able to read and write simple code.
## 0.1.2 &nbsp; Content Structure
The main contents of the book are shown in the Figure 0-1 .
- **Complexity Analysis**: dimensions and methods of evaluation of data structures and algorithms. Methods of deriving time complexity, space complexity, common types, examples, etc.
- **Data Structures**: basic data types, classification methods of data structures. Definition, advantages and disadvantages, common operations, common types, typical applications, implementation methods of data structures such as arrays, linked lists, stacks, queues, hash tables, trees, heaps, graphs, etc.
- **Algorithms**: definitions, advantages and disadvantages, efficiency, application scenarios, solution steps, sample topics of search, sorting algorithms, divide and conquer, backtracking algorithms, dynamic programming, greedy algorithms, and more.
![Hello Algo content structure](about_the_book.assets/hello_algo_mindmap.jpg){ class="animation-figure" }
<p align="center"> Figure 0-1 &nbsp; Hello Algo content structure </p>
## 0.1.3 &nbsp; Acknowledgements
During the creation of this book, I received help from many people, including but not limited to:
- Thank you to my mentor at the company, Dr. Shih Lee, for encouraging me to "get moving" during one of our conversations, which strengthened my resolve to write this book.
- I would like to thank my girlfriend Bubbles for being the first reader of this book, and for making many valuable suggestions from the perspective of an algorithm whiz, making this book more suitable for newbies.
- Thanks to Tengbao, Qibao, and Feibao for coming up with a creative name for this book that evokes fond memories of writing the first line of code "Hello World!".
- Thanks to Sutong for designing the beautiful cover and logo for this book and patiently revising it many times under my OCD.
- Thanks to @squidfunk for writing layout suggestions and for developing the open source documentation theme [Material-for-MkDocs](https://github.com/squidfunk/mkdocs-material/tree/master).
During the writing process, I read many textbooks and articles on data structures and algorithms. These works provide excellent models for this book and ensure the accuracy and quality of its contents. I would like to thank all my teachers and predecessors for their outstanding contributions!
This book promotes a hands-on approach to learning, and in this respect is heavily inspired by ["Hands-On Learning for Depth"](https://github.com/d2l-ai/d2l-zh). I highly recommend this excellent book to all readers.
A heartfelt thank you to my parents, it is your constant support and encouragement that gives me the opportunity to do this fun-filled thing.

@ -0,0 +1,24 @@
---
comments: true
icon: material/book-open-outline
---
# 第 0 章 &nbsp; Preface
<div class="center-table" markdown>
![Preface](../assets/covers/chapter_preface.jpg){ width="600" }{ class="cover-image" }
</div>
!!! abstract
Algorithms are like a beautiful symphony, with each line of code flowing like a rhythm.
May this book ring softly in your head, leaving a unique and profound melody.
## 本章内容
- [0.1 &nbsp; The Book](https://www.hello-algo.com/chapter_preface/about_the_book/)
- [0.2 &nbsp; How to Read](https://www.hello-algo.com/chapter_preface/suggestions/)
- [0.3 &nbsp; Summary](https://www.hello-algo.com/chapter_preface/summary/)

@ -0,0 +1,240 @@
---
comments: true
---
# 0.2 &nbsp; How To Read
!!! tip
For the best reading experience, it is recommended that you read through this section.
## 0.2.1 &nbsp; Conventions Of Style
- Those labeled `*` after the title are optional chapters with relatively difficult content. If you have limited time, it is advisable to skip them.
- Proper nouns and words and phrases with specific meanings are marked with `"double quotes"` to avoid ambiguity.
- Important proper nouns and their English translations are marked with `" "` in parentheses, e.g. `"array array"` . It is recommended to memorize them for reading the literature.
- **Bolded text** Indicates key content or summary statements, which deserve special attention.
- When it comes to terms that are inconsistent between programming languages, this book follows Python, for example using $\text{None}$ to mean "empty".
- This book partially abandons the specification of annotations in programming languages in exchange for a more compact layout of the content. There are three main types of annotations: title annotations, content annotations, and multi-line annotations.
=== "Python"
```python title=""
"""Header comments for labeling functions, classes, test samples, etc.""""
# Content comments for detailed code solutions
"""
multi-line
marginal notes
"""
```
=== "C++"
```cpp title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "Java"
```java title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "C#"
```csharp title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "Go"
```go title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "Swift"
```swift title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "JS"
```javascript title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "TS"
```typescript title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "Dart"
```dart title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "Rust"
```rust title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "C"
```c title=""
/* Header comments for labeling functions, classes, test samples, etc. */
// Content comments for detailed code solutions.
/**
* multi-line
* marginal notes
*/
```
=== "Zig"
```zig title=""
// Header comments for labeling functions, classes, test samples, etc.
// Content comments for detailed code solutions.
// Multi-line
// Annotation
```
## 0.2.2 &nbsp; Learn Efficiently In Animated Graphic Solutions
Compared with text, videos and pictures have a higher degree of information density and structure and are easier to understand. In this book, **key and difficult knowledge will be presented mainly in the form of animations and graphs**, while the text serves as an explanation and supplement to the animations and graphs.
If, while reading the book, you find that a particular paragraph provides an animation or a graphic solution as shown below, **please use the figure as the primary source and the text as a supplement and synthesize the two to understand the content**.
![Example animation](../index.assets/animation.gif){ class="animation-figure" }
<p align="center"> Figure 0-2 &nbsp; Example animation </p>
## 0.2.3 &nbsp; Deeper Understanding In Code Practice
The companion code for this book is hosted in the [GitHub repository](https://github.com/krahets/hello-algo). As shown in the Figure 0-3 , **the source code is accompanied by test samples that can be run with a single click**.
If time permits, **it is recommended that you refer to the code and knock it through on your own**. If you have limited time to study, please read through and run all the code at least once.
The process of writing code is often more rewarding than reading it. **Learning by doing is really learning**.
![Running code example](../index.assets/running_code.gif){ class="animation-figure" }
<p align="center"> Figure 0-3 &nbsp; Running code example </p>
The preliminaries for running the code are divided into three main steps.
**Step 1: Install the local programming environment**. Please refer to [Appendix Tutorial](https://www.hello-algo.com/chapter_appendix/installation/) for installation, or skip this step if already installed.
**Step 2: Clone or download the code repository**. If [Git](https://git-scm.com/downloads) is already installed, you can clone this repository with the following command.
```shell
git clone https://github.com/krahets/hello-algo.git
```
Of course, you can also in the location shown in the Figure 0-4 , click "Download ZIP" directly download the code zip, and then in the local solution.
![Clone repository with download code](suggestions.assets/download_code.png){ class="animation-figure" }
<p align="center"> Figure 0-4 &nbsp; Clone repository with download code </p>
**Step 3: Run the source code**. As shown in the Figure 0-5 , for the code block labeled with the file name at the top, we can find the corresponding source code file in the `codes` folder of the repository. The source code files can be run with a single click, which will help you save unnecessary debugging time and allow you to focus on what you are learning.
![Code block with corresponding source file](suggestions.assets/code_md_to_repo.png){ class="animation-figure" }
<p align="center"> Figure 0-5 &nbsp; Code block with corresponding source file </p>
## 0.2.4 &nbsp; Growing Together In Questioning And Discussion
While reading this book, please don't skip over the points that you didn't learn. **Feel free to ask your questions in the comment section**. We will be happy to answer them and can usually respond within two days.
As you can see in the Figure 0-6 , each post comes with a comment section at the bottom. I hope you'll pay more attention to the comments section. On the one hand, you can learn about the problems that people encounter, so as to check the gaps and stimulate deeper thinking. On the other hand, we expect you to generously answer other partners' questions, share your insights, and help others improve.
![Example of comment section](../index.assets/comment.gif){ class="animation-figure" }
<p align="center"> Figure 0-6 &nbsp; Example of comment section </p>
## 0.2.5 &nbsp; Algorithm Learning Route
From a general point of view, we can divide the process of learning data structures and algorithms into three stages.
1. **Introduction to Algorithms**. We need to familiarize ourselves with the characteristics and usage of various data structures and learn about the principles, processes, uses and efficiency of different algorithms.
2. **Brush up on algorithm questions**. It is recommended to start brushing from popular topics, such as [Sword to Offer](https://leetcode.cn/studyplan/coding-interviews/) and [LeetCode Hot 100](https://leetcode.cn/studyplan/top-100- liked/), first accumulate at least 100 questions to familiarize yourself with mainstream algorithmic problems. Forgetfulness can be a challenge when first brushing up, but rest assured that this is normal. We can follow the "Ebbinghaus Forgetting Curve" to review the questions, and usually after 3-5 rounds of repetitions, we will be able to memorize them.
3. **Build the knowledge system**. In terms of learning, we can read algorithm column articles, solution frameworks and algorithm textbooks to continuously enrich the knowledge system. In terms of brushing, we can try to adopt advanced brushing strategies, such as categorizing by topic, multiple solutions, multiple solutions, etc. Related brushing tips can be found in various communities.
As shown in the Figure 0-7 , this book mainly covers "Phase 1" and is designed to help you start Phase 2 and 3 more efficiently.
![algorithm learning route](suggestions.assets/learning_route.png){ class="animation-figure" }
<p align="center"> Figure 0-7 &nbsp; algorithm learning route </p>

@ -0,0 +1,12 @@
---
comments: true
---
# 0.3 &nbsp; Summary
- The main audience of this book is beginners in algorithm. If you already have some basic knowledge, this book can help you systematically review your algorithm knowledge, and the source code in this book can also be used as a "Coding Toolkit".
- The book consists of three main sections, Complexity Analysis, Data Structures, and Algorithms, covering most of the topics in the field.
- For newcomers to algorithms, it is crucial to read an introductory book in the beginning stages to avoid many detours or common pitfalls.
- Animations and graphs within the book are usually used to introduce key points and difficult knowledge. These should be given more attention when reading the book.
- Practice is the best way to learn programming. It is highly recommended that you run the source code and type in the code yourself.
- Each chapter in the web version of this book features a discussion forum, and you are welcome to share your questions and insights at any time.

@ -0,0 +1 @@
<svg width="358" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-3437 -1242)"><g><path d="M3438 1313C3438 1276 3468 1246 3505 1246L3726 1246C3763 1246 3793 1276 3793 1313 3793 1350 3763 1380 3726 1380L3505 1380C3468 1380 3438 1350 3438 1313Z" fill="#55AEA6" fill-rule="evenodd" fill-opacity="1"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="46" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 3606.97 1329)">中文版</text><g><g><g><path d="M0 17.2C0 12.4566 3.85656 8.59999 8.59999 8.59999L34.4 8.59999 40.85 8.59999 43 8.59999 77.3999 8.59999C82.1434 8.59999 85.9999 12.4566 85.9999 17.2L85.9999 51.6C85.9999 56.3434 82.1434 60.2 77.3999 60.2L43 60.2 40.85 60.2 34.4 60.2 8.59999 60.2C3.85656 60.2 0 56.3434 0 51.6L0 17.2ZM43 17.2 43 51.6 77.3999 51.6 77.3999 17.2 43 17.2ZM23.959 23.6365C23.529 22.669 22.5615 22.0375 21.5 22.0375 20.4384 22.0375 19.4709 22.669 19.0409 23.6365L10.4409 42.9865C9.83624 44.3437 10.4544 45.9293 11.8116 46.534 13.1687 47.1387 14.7544 46.5206 15.3591 45.1634L16.555 42.4625 26.445 42.4625 27.6409 45.1634C28.2456 46.5206 29.8312 47.1253 31.1884 46.534 32.5456 45.9428 33.1503 44.3437 32.559 42.9865L23.959 23.6365ZM21.5 31.3362 24.0531 37.0875 18.9469 37.0875 21.5 31.3362ZM60.2 22.0375C61.6781 22.0375 62.8875 23.2469 62.8875 24.725L62.8875 25.2625 68.7999 25.2625 70.95 25.2625C72.4281 25.2625 73.6374 26.4719 73.6374 27.95 73.6374 29.4281 72.4281 30.6375 70.95 30.6375L70.6812 30.6375 70.4662 31.2422C69.2703 34.5209 67.4562 37.504 65.145 40.0303 65.2659 40.1109 65.3868 40.1781 65.5078 40.2453L68.0474 41.7637C69.324 42.5297 69.7271 44.1825 68.9746 45.4456 68.2221 46.7087 66.5559 47.1253 65.2928 46.3728L62.7531 44.8543C62.1484 44.4915 61.5706 44.1153 60.9928 43.7122 59.5684 44.72 58.05 45.5934 56.424 46.319L55.9403 46.534C54.5831 47.1387 52.9975 46.5206 52.3928 45.1634 51.7881 43.8062 52.4062 42.2206 53.7634 41.6159L54.2472 41.4009C55.1071 41.0112 55.9403 40.5812 56.7331 40.084L55.0937 38.4447C54.0456 37.3965 54.0456 35.69 55.0937 34.6418 56.1418 33.5937 57.8484 33.5937 58.8965 34.6418L60.8584 36.6037 60.9256 36.6709C62.5918 34.9106 63.949 32.8681 64.93 30.624L60.2 30.624 50.525 30.624C49.0468 30.624 47.8375 29.4147 47.8375 27.9365 47.8375 26.4584 49.0468 25.249 50.525 25.249L57.5125 25.249 57.5125 24.7115C57.5125 23.2334 58.7218 22.024 60.2 22.024Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00291 3499 1278)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

@ -0,0 +1 @@
<svg width="358" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-2699 -1242)"><g><path d="M2702 1313C2702 1276 2732 1246 2769 1246L2989 1246C3026 1246 3056 1276 3056 1313 3056 1350 3026 1380 2989 1380L2769 1380C2732 1380 2702 1350 2702 1313Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="1"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="46" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2870.4 1329)">中文版</text><g><g><g><path d="M0 17.2C0 12.4566 3.85656 8.59999 8.59999 8.59999L34.4 8.59999 40.85 8.59999 43 8.59999 77.3999 8.59999C82.1434 8.59999 85.9999 12.4566 85.9999 17.2L85.9999 51.6C85.9999 56.3434 82.1434 60.2 77.3999 60.2L43 60.2 40.85 60.2 34.4 60.2 8.59999 60.2C3.85656 60.2 0 56.3434 0 51.6L0 17.2ZM43 17.2 43 51.6 77.3999 51.6 77.3999 17.2 43 17.2ZM23.959 23.6365C23.529 22.669 22.5615 22.0375 21.5 22.0375 20.4384 22.0375 19.4709 22.669 19.0409 23.6365L10.4409 42.9865C9.83624 44.3437 10.4544 45.9293 11.8116 46.534 13.1687 47.1387 14.7544 46.5206 15.3591 45.1634L16.555 42.4625 26.445 42.4625 27.6409 45.1634C28.2456 46.5206 29.8312 47.1253 31.1884 46.534 32.5456 45.9428 33.1503 44.3437 32.559 42.9865L23.959 23.6365ZM21.5 31.3362 24.0531 37.0875 18.9469 37.0875 21.5 31.3362ZM60.2 22.0375C61.6781 22.0375 62.8875 23.2469 62.8875 24.725L62.8875 25.2625 68.7999 25.2625 70.95 25.2625C72.4281 25.2625 73.6374 26.4719 73.6374 27.95 73.6374 29.4281 72.4281 30.6375 70.95 30.6375L70.6812 30.6375 70.4662 31.2422C69.2703 34.5209 67.4562 37.504 65.145 40.0303 65.2659 40.1109 65.3868 40.1781 65.5078 40.2453L68.0474 41.7637C69.324 42.5297 69.7271 44.1825 68.9746 45.4456 68.2221 46.7087 66.5559 47.1253 65.2928 46.3728L62.7531 44.8543C62.1484 44.4915 61.5706 44.1153 60.9928 43.7122 59.5684 44.72 58.05 45.5934 56.424 46.319L55.9403 46.534C54.5831 47.1387 52.9975 46.5206 52.3928 45.1634 51.7881 43.8062 52.4062 42.2206 53.7634 41.6159L54.2472 41.4009C55.1071 41.0112 55.9403 40.5812 56.7331 40.084L55.0937 38.4447C54.0456 37.3965 54.0456 35.69 55.0937 34.6418 56.1418 33.5937 57.8484 33.5937 58.8965 34.6418L60.8584 36.6037 60.9256 36.6709C62.5918 34.9106 63.949 32.8681 64.93 30.624L60.2 30.624 50.525 30.624C49.0468 30.624 47.8375 29.4147 47.8375 27.9365 47.8375 26.4584 49.0468 25.249 50.525 25.249L57.5125 25.249 57.5125 24.7115C57.5125 23.2334 58.7218 22.024 60.2 22.024Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00291 2762 1278)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

@ -0,0 +1 @@
<svg width="358" height="138" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-3437 -838)"><g><path d="M3438 907C3438 869.997 3468 840 3505 840L3726 840C3763 840 3793 869.997 3793 907 3793 944.004 3763 974.001 3726 974.001L3505 974.001C3468 974.001 3438 944.004 3438 907Z" fill="#55AEA6" fill-rule="evenodd" fill-opacity="1"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 3629.6 924)">PDF</text><g><g><g><path d="M3515 882.125C3515 877.644 3518.64 874 3523.12 874L3543.44 874 3543.44 890.25C3543.44 892.497 3545.25 894.313 3547.5 894.313L3563.75 894.313 3563.75 912.594 3537.34 912.594C3532.86 912.594 3529.22 916.237 3529.22 920.719L3529.22 939 3523.12 939C3518.64 939 3515 935.357 3515 930.875L3515 882.125ZM3563.75 890.25 3547.5 890.25 3547.5 874 3563.75 890.25ZM3537.34 918.688 3541.41 918.688C3545.33 918.688 3548.52 921.874 3548.52 925.797 3548.52 929.72 3545.33 932.906 3541.41 932.906L3539.38 932.906 3539.38 936.969C3539.38 938.086 3538.46 939 3537.34 939 3536.23 939 3535.31 938.086 3535.31 936.969L3535.31 930.875 3535.31 920.719C3535.31 919.602 3536.23 918.688 3537.34 918.688ZM3541.41 928.844C3543.09 928.844 3544.45 927.486 3544.45 925.797 3544.45 924.109 3543.09 922.75 3541.41 922.75L3539.38 922.75 3539.38 928.844 3541.41 928.844ZM3553.59 918.688 3557.66 918.688C3561.02 918.688 3563.75 921.417 3563.75 924.781L3563.75 932.906C3563.75 936.271 3561.02 939 3557.66 939L3553.59 939C3552.48 939 3551.56 938.086 3551.56 936.969L3551.56 920.719C3551.56 919.602 3552.48 918.688 3553.59 918.688ZM3557.66 934.938C3558.77 934.938 3559.69 934.024 3559.69 932.906L3559.69 924.781C3559.69 923.664 3558.77 922.75 3557.66 922.75L3555.62 922.75 3555.62 934.938 3557.66 934.938ZM3567.81 920.719C3567.81 919.602 3568.73 918.688 3569.84 918.688L3575.94 918.688C3577.05 918.688 3577.97 919.602 3577.97 920.719 3577.97 921.836 3577.05 922.75 3575.94 922.75L3571.88 922.75 3571.88 926.813 3575.94 926.813C3577.05 926.813 3577.97 927.727 3577.97 928.844 3577.97 929.961 3577.05 930.875 3575.94 930.875L3571.88 930.875 3571.88 936.969C3571.88 938.086 3570.96 939 3569.84 939 3568.73 939 3567.81 938.086 3567.81 936.969L3567.81 928.844 3567.81 920.719Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -0,0 +1 @@
<svg width="358" height="138" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-2699 -838)"><g><path d="M2702 907C2702 869.997 2732 840 2769 840L2989 840C3026 840 3056 869.997 3056 907 3056 944.003 3026 974 2989 974L2769 974C2732 974 2702 944.003 2702 907Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="1"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2893.03 924)">PDF</text><g><g><g><path d="M2779 882.125C2779 877.644 2782.64 874 2787.12 874L2807.44 874 2807.44 890.25C2807.44 892.497 2809.25 894.313 2811.5 894.313L2827.75 894.313 2827.75 912.594 2801.34 912.594C2796.86 912.594 2793.22 916.237 2793.22 920.719L2793.22 939 2787.12 939C2782.64 939 2779 935.357 2779 930.875L2779 882.125ZM2827.75 890.25 2811.5 890.25 2811.5 874 2827.75 890.25ZM2801.34 918.688 2805.41 918.688C2809.33 918.688 2812.52 921.874 2812.52 925.797 2812.52 929.72 2809.33 932.906 2805.41 932.906L2803.37 932.906 2803.37 936.969C2803.37 938.086 2802.46 939 2801.34 939 2800.23 939 2799.31 938.086 2799.31 936.969L2799.31 930.875 2799.31 920.719C2799.31 919.602 2800.23 918.688 2801.34 918.688ZM2805.41 928.844C2807.09 928.844 2808.45 927.486 2808.45 925.797 2808.45 924.109 2807.09 922.75 2805.41 922.75L2803.37 922.75 2803.37 928.844 2805.41 928.844ZM2817.59 918.688 2821.66 918.688C2825.02 918.688 2827.75 921.417 2827.75 924.781L2827.75 932.906C2827.75 936.271 2825.02 939 2821.66 939L2817.59 939C2816.48 939 2815.56 938.086 2815.56 936.969L2815.56 920.719C2815.56 919.602 2816.48 918.688 2817.59 918.688ZM2821.66 934.938C2822.77 934.938 2823.69 934.024 2823.69 932.906L2823.69 924.781C2823.69 923.664 2822.77 922.75 2821.66 922.75L2819.62 922.75 2819.62 934.938 2821.66 934.938ZM2831.81 920.719C2831.81 919.602 2832.73 918.688 2833.84 918.688L2839.94 918.688C2841.05 918.688 2841.97 919.602 2841.97 920.719 2841.97 921.836 2841.05 922.75 2839.94 922.75L2835.87 922.75 2835.87 926.813 2839.94 926.813C2841.05 926.813 2841.97 927.727 2841.97 928.844 2841.97 929.961 2841.05 930.875 2839.94 930.875L2835.87 930.875 2835.87 936.969C2835.87 938.086 2834.96 939 2833.84 939 2832.73 939 2831.81 938.086 2831.81 936.969L2831.81 928.844 2831.81 920.719Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -0,0 +1 @@
<svg width="358" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><defs><clipPath id="clip0"><rect x="3501" y="672" width="82" height="65"/></clipPath><clipPath id="clip1"><rect x="3501" y="672" width="82" height="65"/></clipPath><clipPath id="clip2"><rect x="3501" y="672" width="82" height="65"/></clipPath></defs><g transform="translate(-3437 -632)"><g><path d="M3438 704C3438 666.997 3468 637 3505 637L3726 637C3763 637 3793 666.997 3793 704 3793 741.003 3763 771 3726 771L3505 771C3468 771 3438 741.003 3438 704Z" fill="#55AEA6" fill-rule="evenodd" fill-opacity="1"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 3625.58 721)">Web</text><g clip-path="url(#clip0)"><g clip-path="url(#clip1)"><g clip-path="url(#clip2)"><path d="M16.25 0C11.7685 0 8.125 3.64355 8.125 8.125L8.125 36.5625 2.4375 36.5625C1.0918 36.5625 0 37.6543 0 39 0 44.3828 4.36719 48.75 9.75 48.75L40.625 48.75 40.625 36.5625 16.25 36.5625 16.25 8.125 56.875 8.125 56.875 12.1875 65 12.1875 65 8.125C65 3.64355 61.3564 0 56.875 0L16.25 0ZM65 16.25 50.7812 16.25C47.417 16.25 44.6875 18.9795 44.6875 22.3437L44.6875 58.9062C44.6875 62.2705 47.417 65 50.7812 65L75.1562 65C78.5205 65 81.25 62.2705 81.25 58.9062L81.25 32.5 69.0625 32.5C66.8154 32.5 65 30.6846 65 28.4375L65 16.25ZM69.0625 16.25 69.0625 28.4375 81.25 28.4375 69.0625 16.25Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1" transform="matrix(1.00923 0 0 1 3501 672)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -0,0 +1 @@
<svg width="358" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><defs><clipPath id="clip0"><rect x="2765" y="672" width="81" height="65"/></clipPath><clipPath id="clip1"><rect x="2765" y="672" width="81" height="65"/></clipPath><clipPath id="clip2"><rect x="2765" y="672" width="81" height="65"/></clipPath></defs><g transform="translate(-2699 -632)"><g><path d="M2702 704C2702 666.997 2732 637 2769 637L2989 637C3026 637 3056 666.997 3056 704 3056 741.003 3026 771 2989 771L2769 771C2732 771 2702 741.003 2702 704Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="1"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2889.02 721)">Web</text><g clip-path="url(#clip0)"><g clip-path="url(#clip1)"><g clip-path="url(#clip2)"><path d="M16.2 0C11.7323 0 8.09998 3.63233 8.09998 8.09998L8.09998 36.4499 2.42999 36.4499C1.08843 36.4499 0 37.5383 0 38.8799 0 44.2461 4.35374 48.5999 9.71997 48.5999L40.4999 48.5999 40.4999 36.4499 16.2 36.4499 16.2 8.09998 56.6998 8.09998 56.6998 12.15 64.7998 12.15 64.7998 8.09998C64.7998 3.63233 61.1675 0 56.6998 0L16.2 0ZM64.7998 16.2 50.6249 16.2C47.271 16.2 44.5499 18.921 44.5499 22.2749L44.5499 58.7248C44.5499 62.0787 47.271 64.7998 50.6249 64.7998L74.9248 64.7998C78.2787 64.7998 80.9998 62.0787 80.9998 58.7248L80.9998 32.3999 68.8498 32.3999C66.6097 32.3999 64.7998 30.5901 64.7998 28.3499L64.7998 16.2ZM68.8498 16.2 68.8498 28.3499 80.9998 28.3499 68.8498 16.2Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00309 2765 672)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -0,0 +1,173 @@
---
comments: true
glightbox: false
hide:
- footer
- toc
- edit
---
<div class="header-img-div" style="max-width: 500px;">
<img src="index.assets/conceptual_rendering.png" style="width: 37%; height: auto;">
<img src="index.assets/hello_algo_mindmap_tp.png" style="width: 63%; height: auto;">
</div>
<h2 align="center">Hello Algo</h2>
<p align="center">Data Structures and Algorithms Crash Course with Animated Illustrations and Off-the-Shelf Code</p>
<p align="center">
<a href="https://github.com/krahets/hello-algo">
<img alt="GitHub repo stars" src="https://img.shields.io/github/stars/krahets/hello-algo?style=social&link=https%3A%2F%2Fgithub.com%2Fkrahets%2Fhello-algo">
</a>
&nbsp;
<a href="https://github.com/krahets/hello-algo/releases">
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/krahets/hello-algo/total?style=social&logo=gitbook&logoColor=black&label=Downloads">
</a>
&nbsp;
<a href="https://github.com/krahets/hello-algo">
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors-anon/krahets/hello-algo?style=social&logo=git&logoColor=%23101010">
</a>
</p>
<p align="center">
<a href="https://www.hello-algo.com/en/chapter_preface/" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M249.6 471.5c10.8 3.8 22.4-4.1 22.4-15.5V78.6c0-4.2-1.6-8.4-5-11C247.4 52 202.4 32 144 32C93.5 32 46.3 45.3 18.1 56.1C6.8 60.5 0 71.7 0 83.8V454.1c0 11.9 12.8 20.2 24.1 16.5C55.6 460.1 105.5 448 144 448c33.9 0 79 14 105.6 23.5zm76.8 0C353 462 398.1 448 432 448c38.5 0 88.4 12.1 119.9 22.6c11.3 3.8 24.1-4.6 24.1-16.5V83.8c0-12.1-6.8-23.3-18.1-27.6C529.7 45.3 482.5 32 432 32c-58.4 0-103.4 20-123 35.6c-3.3 2.6-5 6.8-5 11V456c0 11.4 11.7 19.3 22.4 15.5z"/></svg>
Dive In
</a>
<a href="https://github.com/krahets/hello-algo" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg" height="16px" width="15.5px" viewBox="0 0 496 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
Clone Repo
</a>
<a href="https://github.com/krahets/hello-algo/releases" class="rounded-button">
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M0 64C0 28.7 28.7 0 64 0L224 0l0 128c0 17.7 14.3 32 32 32l128 0 0 144-208 0c-35.3 0-64 28.7-64 64l0 144-48 0c-35.3 0-64-28.7-64-64L0 64zm384 64l-128 0L256 0 384 128zM176 352l32 0c30.9 0 56 25.1 56 56s-25.1 56-56 56l-16 0 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-80c0-8.8 7.2-16 16-16zm32 80c13.3 0 24-10.7 24-24s-10.7-24-24-24l-16 0 0 48 16 0zm96-80l32 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-32 0c-8.8 0-16-7.2-16-16l0-128c0-8.8 7.2-16 16-16zm32 128c8.8 0 16-7.2 16-16l0-64c0-8.8-7.2-16-16-16l-16 0 0 96 16 0zm80-112c0-8.8 7.2-16 16-16l48 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 32 32 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 48c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-64 0-64z"/></svg>
Get PDF
</a>
</p>
<p align="center">
<img src="https://img.shields.io/badge/Python-snow?logo=python&logoColor=3776AB">
<img src="https://img.shields.io/badge/C%2B%2B-snow?logo=c%2B%2B&logoColor=00599C">
<img src="https://img.shields.io/badge/Java-snow?logo=coffeescript&logoColor=FC4C02">
<img src="https://img.shields.io/badge/C%23-snow?logo=csharp&logoColor=512BD4">
<img src="https://img.shields.io/badge/Go-snow?logo=go&logoColor=00ADD8">
<img src="https://img.shields.io/badge/Swift-snow?logo=swift&logoColor=F05138">
<img src="https://img.shields.io/badge/JavaScript-snow?logo=javascript&logoColor=E9CE30">
<img src="https://img.shields.io/badge/TypeScript-snow?logo=typescript&logoColor=3178C6">
<img src="https://img.shields.io/badge/Dart-snow?logo=dart&logoColor=0175C2">
<img src="https://img.shields.io/badge/Rust-snow?logo=rust&logoColor=000000">
<img src="https://img.shields.io/badge/C-snow?logo=c&logoColor=A8B9CC">
<img src="https://img.shields.io/badge/Zig-snow?logo=zig&logoColor=F7A41D">
<img src="https://img.shields.io/badge/Stay%20Tuned-snow">
</p>
---
<h3 align="center">Endorsements</h3>
<div style="display: flex;">
<div class="admonition quote" style="flex: 1; margin-right: 0.4rem;">
<p class="admonition-title">Quote</p>
<p>"An easy-to-understand book on data structures and algorithms, which guides readers to learn by minds-on and hands-on. Strongly recommended for algorithm beginners!"</p>
<p><strong>—— Junhui Deng, Professor of Computer Science, Tsinghua University</strong></p>
</div>
<div class="admonition quote" style="flex: 1; margin-left: 0.4rem;">
<p class="admonition-title">Quote</p>
<p>"If I had 'Hello Algo' when I was learning data structures and algorithms, it would have been 10 times easier!"</p>
<p><strong>—— Mu Li, Senior Principal Scientist, Amazon</strong></p>
</div>
</div>
---
<div style="display: flex; align-items: center; margin: 2rem auto;">
<div style="flex: 1; margin: 0 2rem; display: flex; flex-direction: column; align-items: center;">
<div style="display: flex; flex-direction: column; align-items: center;">
<h3>Animated illustrations</h3>
<svg xmlns="http://www.w3.org/2000/svg" height="28" width="28" viewBox="0 0 640 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path fill="var(--md-primary-bg-color)" d="M256 0H576c35.3 0 64 28.7 64 64V288c0 35.3-28.7 64-64 64H256c-35.3 0-64-28.7-64-64V64c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6h80 48H552c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128h96V384v32c0 17.7 14.3 32 32 32H320c17.7 0 32-14.3 32-32V384H512v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V208c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V312c0-8.8-7.2-16-16-16H72zm0 104c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16H88c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H72zm336 16v16c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16V416c0-8.8-7.2-16-16-16H424c-8.8 0-16 7.2-16 16z"/></svg>
</div>
<p style="text-align: center;">Easy to understand</br>Smooth learning curve</p>
</div>
<img src="index.assets/animation.gif" class="cover-image" style="flex-shrink: 0; width: auto; max-width: 50%; border-radius: 0.5rem;">
</div>
<div class="admonition quote">
<p align="center">"A picture is worth a thousand words."</p>
</div>
<div style="display: flex; align-items: center; margin: 2rem auto;">
<img src="index.assets/running_code.gif" class="cover-image" style="flex-shrink: 0; width: auto; max-width: 50%; border-radius: 0.5rem;">
<div style="flex: 1; margin: 0 2rem; display: flex; flex-direction: column; align-items: center;">
<div style="display: flex; flex-direction: column; align-items: center;">
<h3>Off-the-Shelf Code</h3>
<svg xmlns="http://www.w3.org/2000/svg" height="28" width="28" viewBox="0 0 640 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path fill="var(--md-primary-bg-color)" d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z"/></svg>
</div>
<p style="text-align: center;">Multi programming languages</br>Run with one click</p>
</div>
</div>
<div class="admonition quote">
<p align="center">"Talk is cheap. Show me the code."</p>
</div>
<div style="display: flex; align-items: center; margin: 2rem auto;">
<div style="flex: 1; margin: 0 2rem; display: flex; flex-direction: column; align-items: center;">
<div style="display: flex; flex-direction: column; align-items: center;">
<h3>Learning Together</h3>
<svg xmlns="http://www.w3.org/2000/svg" height="28" width="28" viewBox="0 0 640 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path fill="var(--md-primary-bg-color)" d="M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.7 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z"/></svg>
</div>
<p style="text-align: center;">Discussion and questions welcome</br>Readers progress together</p>
</div>
<img src="index.assets/comment.gif" class="cover-image" style="flex-shrink: 0; width: auto; max-width: 50%; border-radius: 0.5rem;">
</div>
<div class="admonition quote">
<p align="center">"Chase the wind and moon, never stopping"</p>
<p align="center">"Beyond the plains, there are spring mountains"</p>
</div>
---
<h3 align="center"> Preface </h3>
Two years ago, I shared the "Sword Offer" series of problem solutions on LeetCode, which received much love and support from many students. During my interactions with readers, the most common question I encountered was "How to get started with algorithms." Gradually, I developed a deep interest in this question.
Blindly solving problems seems to be the most popular method, being simple, direct, and effective. However, problem-solving is like playing a "Minesweeper" game, where students with strong self-learning abilities can successfully clear the mines one by one, but those with insufficient foundations may end up bruised from explosions, retreating step by step in frustration. Thoroughly reading textbooks is also common, but for students aiming for job applications, the energy consumed by graduation, resume submissions, and preparing for written tests and interviews makes tackling thick books a daunting challenge.
If you are facing similar troubles, then you are lucky to have found this book. This book is my answer to this question, not necessarily the best solution, but at least an active attempt. Although this book won't directly land you an Offer, it will guide you through the "knowledge map" of data structures and algorithms, help you understand the shape, size, and distribution of different "mines," and equip you with various "demining methods." With these skills, I believe you can more comfortably solve problems and read literature, gradually building a complete knowledge system.
I deeply agree with Professor Feynman's saying: "Knowledge isn't free. You have to pay attention." In this sense, this book is not entirely "free." To not disappoint the precious "attention" you pay to this book, I will do my utmost, investing the greatest "attention" to complete the creation of this book.
<h3 align="left"> Author </h3>
Yudong Jin([Krahets](https://leetcode.cn/u/jyd/)), Senior Algorithm Engineer in a top tech company, Master's degree from Shanghai Jiao Tong University. The highest-read blogger across the entire LeetCode, his published ["Illustration of Algorithm Data Structures"](https://leetcode.cn/leetbook/detail/illustration-of-algorithm/) has been subscribed to by over 300k.
---
<h3 align="center"> Contribution </h3>
This book is continuously improved with the joint efforts of many contributors from the open-source community. Thanks to each writer who invested their time and energy, listed in the order generated by GitHub:
<p align="center">
<a href="https://github.com/krahets/hello-algo/graphs/contributors">
<img width="550" src="https://contrib.rocks/image?repo=krahets/hello-algo">
</a>
</p>
The code review work for this book was completed by Gonglja, gvenusleo, hpstory, justintse, krahets, night-cruise, nuomi1, Reanon, and sjinzh (listed in alphabetical order). Thanks to them for their time and effort, ensuring the standardization and uniformity of the code in various languages.
<div class="center-table">
<table style="border: none;">
<tbody>
<td align="center" style="border: none;"><a href="https://github.com/Gonglja"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/39959756?v=4" width="50px;" alt="Gonglja"/></br><sub><b>Gonglja</b></sub></a></br><sub>C, C++</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/gvenusleo"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/79075347?v=4" width="50px;" alt="gvenusleo"/></br><sub><b>gvenusleo</b></sub></a></br><sub>Dart</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/hpstory"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/33348162?v=4" width="50px;" alt="hpstory"/></br><sub><b>hpstory</b></sub></a></br><sub>C#</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/justin-tse"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/24556310?v=4" width="50px;" alt="justin-tse"/></br><sub><b>justin-tse</b></sub></a></br><sub>JS, TS</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/krahets"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/26993056?v=4" width="50px;" alt="krahets"/></br><sub><b>krahets</b></sub></a></br><sub>Java, Python</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/night-cruise"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/77157236?v=4" width="50px;" alt="night-cruise"/></br><sub><b>night-cruise</b></sub></a></br><sub>Rust</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/nuomi1"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/3739017?v=4" width="50px;" alt="nuomi1"/></br><sub><b>nuomi1</b></sub></a></br><sub>Swift</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/Reanon"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/22005836?v=4" width="50px;" alt="Reanon"/></br><sub><b>Reanon</b></sub></a></br><sub>Go, C</sub></td>
<td align="center" style="border: none;"><a href="https://github.com/sjinzh"><img style="border-radius: 50%;" src="https://avatars.githubusercontent.com/u/99076655?v=4" width="50px;" alt="sjinzh"/></br><sub><b>sjinzh</b></sub></a></br><sub>Rust, Zig</sub></td>
</tbody>
</table>
</div>

@ -1 +1 @@
<svg width="463" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-2493 -1026)"><g><path d="M2497 1098C2497 1061 2527 1031 2564 1031L2885 1031C2922 1031 2952 1061 2952 1098L2952 1098C2952 1135 2922 1165 2885 1165L2564 1165C2527 1165 2497 1135 2497 1098Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="0.901961"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2677.55 1115)">下载</text><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2784.69 1115)">PDF</text><g><g><g><path d="M2577 1074.12C2577 1069.64 2580.64 1066 2585.12 1066L2605.44 1066 2605.44 1082.25C2605.44 1084.5 2607.25 1086.31 2609.5 1086.31L2625.75 1086.31 2625.75 1104.59 2599.34 1104.59C2594.86 1104.59 2591.22 1108.24 2591.22 1112.72L2591.22 1131 2585.12 1131C2580.64 1131 2577 1127.36 2577 1122.88L2577 1074.12ZM2625.75 1082.25 2609.5 1082.25 2609.5 1066 2625.75 1082.25ZM2599.34 1110.69 2603.41 1110.69C2607.33 1110.69 2610.52 1113.87 2610.52 1117.8 2610.52 1121.72 2607.33 1124.91 2603.41 1124.91L2601.38 1124.91 2601.38 1128.97C2601.38 1130.09 2600.46 1131 2599.34 1131 2598.23 1131 2597.31 1130.09 2597.31 1128.97L2597.31 1122.88 2597.31 1112.72C2597.31 1111.6 2598.23 1110.69 2599.34 1110.69ZM2603.41 1120.84C2605.09 1120.84 2606.45 1119.49 2606.45 1117.8 2606.45 1116.11 2605.09 1114.75 2603.41 1114.75L2601.38 1114.75 2601.38 1120.84 2603.41 1120.84ZM2615.59 1110.69 2619.66 1110.69C2623.02 1110.69 2625.75 1113.42 2625.75 1116.78L2625.75 1124.91C2625.75 1128.27 2623.02 1131 2619.66 1131L2615.59 1131C2614.48 1131 2613.56 1130.09 2613.56 1128.97L2613.56 1112.72C2613.56 1111.6 2614.48 1110.69 2615.59 1110.69ZM2619.66 1126.94C2620.77 1126.94 2621.69 1126.02 2621.69 1124.91L2621.69 1116.78C2621.69 1115.66 2620.77 1114.75 2619.66 1114.75L2617.62 1114.75 2617.62 1126.94 2619.66 1126.94ZM2629.81 1112.72C2629.81 1111.6 2630.73 1110.69 2631.84 1110.69L2637.94 1110.69C2639.05 1110.69 2639.97 1111.6 2639.97 1112.72 2639.97 1113.84 2639.05 1114.75 2637.94 1114.75L2633.88 1114.75 2633.88 1118.81 2637.94 1118.81C2639.05 1118.81 2639.97 1119.73 2639.97 1120.84 2639.97 1121.96 2639.05 1122.88 2637.94 1122.88L2633.88 1122.88 2633.88 1128.97C2633.88 1130.09 2632.96 1131 2631.84 1131 2630.73 1131 2629.81 1130.09 2629.81 1128.97L2629.81 1120.84 2629.81 1112.72Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1"/></g></g></g></g></g></svg> <svg width="458" height="138" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-1952 -838)"><g><path d="M1954 907C1954 869.997 1984 840 2021 840L2342 840C2379 840 2409 869.997 2409 907L2409 907C2409 944.003 2379 974 2342 974L2021 974C1984 974 1954 944.003 1954 907Z" fill="#55AEA6" fill-rule="evenodd" fill-opacity="1"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2134.57 924)">下载</text><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2241.71 924)">PDF</text><g><g><g><path d="M2035 882.125C2035 877.644 2038.64 874 2043.12 874L2063.44 874 2063.44 890.25C2063.44 892.497 2065.25 894.313 2067.5 894.313L2083.75 894.313 2083.75 912.594 2057.34 912.594C2052.86 912.594 2049.22 916.237 2049.22 920.719L2049.22 939 2043.12 939C2038.64 939 2035 935.357 2035 930.875L2035 882.125ZM2083.75 890.25 2067.5 890.25 2067.5 874 2083.75 890.25ZM2057.34 918.688 2061.41 918.688C2065.33 918.688 2068.52 921.874 2068.52 925.797 2068.52 929.72 2065.33 932.906 2061.41 932.906L2059.38 932.906 2059.38 936.969C2059.38 938.086 2058.46 939 2057.34 939 2056.23 939 2055.31 938.086 2055.31 936.969L2055.31 930.875 2055.31 920.719C2055.31 919.602 2056.23 918.688 2057.34 918.688ZM2061.41 928.844C2063.09 928.844 2064.45 927.486 2064.45 925.797 2064.45 924.109 2063.09 922.75 2061.41 922.75L2059.38 922.75 2059.38 928.844 2061.41 928.844ZM2073.59 918.688 2077.66 918.688C2081.02 918.688 2083.75 921.417 2083.75 924.781L2083.75 932.906C2083.75 936.271 2081.02 939 2077.66 939L2073.59 939C2072.48 939 2071.56 938.086 2071.56 936.969L2071.56 920.719C2071.56 919.602 2072.48 918.688 2073.59 918.688ZM2077.66 934.938C2078.77 934.938 2079.69 934.024 2079.69 932.906L2079.69 924.781C2079.69 923.664 2078.77 922.75 2077.66 922.75L2075.62 922.75 2075.62 934.938 2077.66 934.938ZM2087.81 920.719C2087.81 919.602 2088.73 918.688 2089.84 918.688L2095.94 918.688C2097.05 918.688 2097.97 919.602 2097.97 920.719 2097.97 921.836 2097.05 922.75 2095.94 922.75L2091.88 922.75 2091.88 926.813 2095.94 926.813C2097.05 926.813 2097.97 927.727 2097.97 928.844 2097.97 929.961 2097.05 930.875 2095.94 930.875L2091.88 930.875 2091.88 936.969C2091.88 938.086 2090.96 939 2089.84 939 2088.73 939 2087.81 938.086 2087.81 936.969L2087.81 928.844 2087.81 920.719Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1"/></g></g></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

@ -1 +1 @@
<svg width="458" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><defs><clipPath id="clip0"><rect x="1801" y="1026" width="458" height="142"/></clipPath><clipPath id="clip1"><rect x="1801" y="1026" width="458" height="142"/></clipPath></defs><g clip-path="url(#clip0)" transform="translate(-1801 -1026)"><g clip-path="url(#clip1)"><path d="M1804 1098C1804 1061 1834 1031 1871 1031L2192 1031C2229 1031 2259 1061 2259 1098L2259 1098C2259 1135 2229 1165 2192 1165L1871 1165C1834 1165 1804 1135 1804 1098Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="0.901961"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1984.07 1115)">下载</text><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2091.21 1115)">PDF</text><g><g><g><path d="M0 7.99999C0 3.5875 3.5875 0 7.99999 0L28 0 28 16C28 18.2125 29.7875 20 32 20L48 20 48 38 22 38C17.5875 38 14 41.5875 14 46L14 63.9999 7.99999 63.9999C3.5875 63.9999 0 60.4124 0 55.9999L0 7.99999ZM48 16 32 16 32 0 48 16ZM22 44 26 44C29.8625 44 33 47.1375 33 50.9999 33 54.8624 29.8625 57.9999 26 57.9999L24 57.9999 24 61.9999C24 63.0999 23.1 63.9999 22 63.9999 20.9 63.9999 20 63.0999 20 61.9999L20 55.9999 20 46C20 44.9 20.9 44 22 44ZM26 53.9999C27.6625 53.9999 29 52.6624 29 50.9999 29 49.3375 27.6625 48 26 48L24 48 24 53.9999 26 53.9999ZM38 44 42 44C45.3125 44 48 46.6875 48 50L48 57.9999C48 61.3124 45.3125 63.9999 42 63.9999L38 63.9999C36.9 63.9999 36 63.0999 36 61.9999L36 46C36 44.9 36.9 44 38 44ZM42 59.9999C43.1 59.9999 44 59.0999 44 57.9999L44 50C44 48.9 43.1 48 42 48L40 48 40 59.9999 42 59.9999ZM51.9999 46C51.9999 44.9 52.8999 44 53.9999 44L59.9999 44C61.0999 44 61.9999 44.9 61.9999 46 61.9999 47.0999 61.0999 48 59.9999 48L55.9999 48 55.9999 51.9999 59.9999 51.9999C61.0999 51.9999 61.9999 52.8999 61.9999 53.9999 61.9999 55.0999 61.0999 55.9999 59.9999 55.9999L55.9999 55.9999 55.9999 61.9999C55.9999 63.0999 55.0999 63.9999 53.9999 63.9999 52.8999 63.9999 51.9999 63.0999 51.9999 61.9999L51.9999 53.9999 51.9999 46Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.01563 1884 1066)"/></g></g></g></g></g></svg> <svg width="459" height="138" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-1223 -838)"><g><path d="M1227 907C1227 869.997 1257 840 1294 840L1614 840C1651 840 1681 869.997 1681 907L1681 907C1681 944.004 1651 974.001 1614 974.001L1294 974C1257 974 1227 944.003 1227 907Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="1"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1406.83 924)">下载</text><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1513.97 924)">PDF</text><g><g><g><path d="M1307 882.125C1307 877.644 1310.64 874 1315.12 874L1335.44 874 1335.44 890.25C1335.44 892.497 1337.25 894.313 1339.5 894.313L1355.75 894.313 1355.75 912.594 1329.34 912.594C1324.86 912.594 1321.22 916.237 1321.22 920.719L1321.22 939 1315.12 939C1310.64 939 1307 935.357 1307 930.875L1307 882.125ZM1355.75 890.25 1339.5 890.25 1339.5 874 1355.75 890.25ZM1329.34 918.688 1333.41 918.688C1337.33 918.688 1340.52 921.874 1340.52 925.797 1340.52 929.72 1337.33 932.906 1333.41 932.906L1331.37 932.906 1331.37 936.969C1331.37 938.086 1330.46 939 1329.34 939 1328.23 939 1327.31 938.086 1327.31 936.969L1327.31 930.875 1327.31 920.719C1327.31 919.602 1328.23 918.688 1329.34 918.688ZM1333.41 928.844C1335.09 928.844 1336.45 927.486 1336.45 925.797 1336.45 924.109 1335.09 922.75 1333.41 922.75L1331.37 922.75 1331.37 928.844 1333.41 928.844ZM1345.59 918.688 1349.66 918.688C1353.02 918.688 1355.75 921.417 1355.75 924.781L1355.75 932.906C1355.75 936.271 1353.02 939 1349.66 939L1345.59 939C1344.48 939 1343.56 938.086 1343.56 936.969L1343.56 920.719C1343.56 919.602 1344.48 918.688 1345.59 918.688ZM1349.66 934.938C1350.77 934.938 1351.69 934.024 1351.69 932.906L1351.69 924.781C1351.69 923.664 1350.77 922.75 1349.66 922.75L1347.62 922.75 1347.62 934.938 1349.66 934.938ZM1359.81 920.719C1359.81 919.602 1360.73 918.688 1361.84 918.688L1367.94 918.688C1369.05 918.688 1369.97 919.602 1369.97 920.719 1369.97 921.836 1369.05 922.75 1367.94 922.75L1363.87 922.75 1363.87 926.813 1367.94 926.813C1369.05 926.813 1369.97 927.727 1369.97 928.844 1369.97 929.961 1369.05 930.875 1367.94 930.875L1363.87 930.875 1363.87 936.969C1363.87 938.086 1362.96 939 1361.84 939 1360.73 939 1359.81 938.086 1359.81 936.969L1359.81 928.844 1359.81 920.719Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1"/></g></g></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

@ -0,0 +1 @@
<svg width="458" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-1952 -1242)"><g><path d="M1954 1313C1954 1276 1984 1246 2021 1246L2342 1246C2379 1246 2409 1276 2409 1313L2409 1313C2409 1350 2379 1380 2342 1380L2021 1380C1984 1380 1954 1350 1954 1313Z" fill="#55AEA6" fill-rule="evenodd" fill-opacity="1"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC,Noto Sans SC_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="700" font-stretch="normal" font-size="41" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2132.59 1328)">English Ed</text><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC,Noto Sans SC_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="700" font-stretch="normal" font-size="41" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2342.28 1328)">.</text><g><g><g><path d="M0 17.2001C0 12.4566 3.85658 8.60003 8.60003 8.60003L34.4001 8.60003 40.8501 8.60003 43.0001 8.60003 77.4003 8.60003C82.1437 8.60003 86.0003 12.4566 86.0003 17.2001L86.0003 51.6002C86.0003 56.3436 82.1437 60.2002 77.4003 60.2002L43.0001 60.2002 40.8501 60.2002 34.4001 60.2002 8.60003 60.2002C3.85658 60.2002 0 56.3436 0 51.6002L0 17.2001ZM43.0001 17.2001 43.0001 51.6002 77.4003 51.6002 77.4003 17.2001 43.0001 17.2001ZM23.9591 23.6366C23.5291 22.6691 22.5616 22.0376 21.5001 22.0376 20.4385 22.0376 19.471 22.6691 19.041 23.6366L10.441 42.9867C9.83628 44.3439 10.4544 45.9295 11.8116 46.5342 13.1688 47.1389 14.7544 46.5208 15.3591 45.1636L16.5551 42.4626 26.4451 42.4626 27.641 45.1636C28.2457 46.5208 29.8314 47.1255 31.1885 46.5342 32.5457 45.943 33.1504 44.3439 32.5592 42.9867L23.9591 23.6366ZM21.5001 31.3364 24.0532 37.0876 18.9469 37.0876 21.5001 31.3364ZM60.2002 22.0376C61.6783 22.0376 62.8877 23.247 62.8877 24.7251L62.8877 25.2626 68.8002 25.2626 70.9502 25.2626C72.4284 25.2626 73.6378 26.472 73.6378 27.9501 73.6378 29.4282 72.4284 30.6376 70.9502 30.6376L70.6815 30.6376 70.4665 31.2423C69.2706 34.5211 67.4565 37.5042 65.1452 40.0305 65.2662 40.1111 65.3871 40.1783 65.508 40.2455L68.0477 41.7639C69.3243 42.5298 69.7274 44.1827 68.9749 45.4458 68.2224 46.7089 66.5562 47.1255 65.293 46.373L62.7533 44.8545C62.1487 44.4917 61.5708 44.1155 60.993 43.7123 59.5686 44.7202 58.0502 45.5936 56.4243 46.3192L55.9405 46.5342C54.5833 47.1389 52.9977 46.5208 52.393 45.1636 51.7883 43.8064 52.4064 42.2208 53.7636 41.6161L54.2474 41.4011C55.1074 41.0114 55.9405 40.5814 56.7333 40.0842L55.0939 38.4448C54.0458 37.3967 54.0458 35.6901 55.0939 34.642 56.1421 33.5939 57.8486 33.5939 58.8968 34.642L60.8587 36.6039 60.9258 36.6711C62.5921 34.9107 63.9493 32.8682 64.9302 30.6242L60.2002 30.6242 50.5252 30.6242C49.047 30.6242 47.8377 29.4148 47.8377 27.9367 47.8377 26.4585 49.047 25.2491 50.5252 25.2491L57.5127 25.2491 57.5127 24.7116C57.5127 23.2335 58.7221 22.0241 60.2002 22.0241Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.0029 2019 1278)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

@ -0,0 +1 @@
<svg width="459" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-1223 -1242)"><g><path d="M1227 1313C1227 1276 1257 1246 1294 1246L1614 1246C1651 1246 1681 1276 1681 1313L1681 1313C1681 1350 1651 1380 1614 1380L1294 1380C1257 1380 1227 1350 1227 1313Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="1"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC,Noto Sans SC_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="700" font-stretch="normal" font-size="41" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1404.85 1328)">English Ed</text><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC,Noto Sans SC_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="700" font-stretch="normal" font-size="41" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1614.54 1328)">.</text><g><g><g><path d="M0 17.2C0 12.4566 3.85656 8.59999 8.59999 8.59999L34.4 8.59999 40.85 8.59999 43 8.59999 77.3999 8.59999C82.1434 8.59999 85.9999 12.4566 85.9999 17.2L85.9999 51.6C85.9999 56.3434 82.1434 60.2 77.3999 60.2L43 60.2 40.85 60.2 34.4 60.2 8.59999 60.2C3.85656 60.2 0 56.3434 0 51.6L0 17.2ZM43 17.2 43 51.6 77.3999 51.6 77.3999 17.2 43 17.2ZM23.959 23.6365C23.529 22.669 22.5615 22.0375 21.5 22.0375 20.4384 22.0375 19.4709 22.669 19.0409 23.6365L10.4409 42.9865C9.83624 44.3437 10.4544 45.9293 11.8116 46.534 13.1687 47.1387 14.7544 46.5206 15.3591 45.1634L16.555 42.4625 26.445 42.4625 27.6409 45.1634C28.2456 46.5206 29.8312 47.1253 31.1884 46.534 32.5456 45.9428 33.1503 44.3437 32.559 42.9865L23.959 23.6365ZM21.5 31.3362 24.0531 37.0875 18.9469 37.0875 21.5 31.3362ZM60.2 22.0375C61.6781 22.0375 62.8875 23.2469 62.8875 24.725L62.8875 25.2625 68.7999 25.2625 70.95 25.2625C72.4281 25.2625 73.6374 26.4719 73.6374 27.95 73.6374 29.4281 72.4281 30.6375 70.95 30.6375L70.6812 30.6375 70.4662 31.2422C69.2703 34.5209 67.4562 37.504 65.145 40.0303 65.2659 40.1109 65.3868 40.1781 65.5078 40.2453L68.0474 41.7637C69.324 42.5297 69.7271 44.1825 68.9746 45.4456 68.2221 46.7087 66.5559 47.1253 65.2928 46.3728L62.7531 44.8543C62.1484 44.4915 61.5706 44.1153 60.9928 43.7122 59.5684 44.72 58.05 45.5934 56.424 46.319L55.9403 46.534C54.5831 47.1387 52.9975 46.5206 52.3928 45.1634 51.7881 43.8062 52.4062 42.2206 53.7634 41.6159L54.2472 41.4009C55.1071 41.0112 55.9403 40.5812 56.7331 40.084L55.0937 38.4447C54.0456 37.3965 54.0456 35.69 55.0937 34.6418 56.1418 33.5937 57.8484 33.5937 58.8965 34.6418L60.8584 36.6037 60.9256 36.6709C62.5918 34.9106 63.949 32.8681 64.93 30.624L60.2 30.624 50.525 30.624C49.0468 30.624 47.8375 29.4147 47.8375 27.9365 47.8375 26.4584 49.0468 25.249 50.525 25.249L57.5125 25.249 57.5125 24.7115C57.5125 23.2334 58.7218 22.024 60.2 22.024Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00291 1291 1278)"/></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -1 +1 @@
<svg width="463" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-2493 -825)"><g><path d="M2497 896C2497 858.997 2527 829 2564 829L2885 829C2922 829 2952 858.997 2952 896L2952 896C2952 933.003 2922 963 2885 963L2564 963C2527 963 2497 933.003 2497 896Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="0.901961"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2680.99 912)">在线阅读</text><g><g><g><path d="M16.2 0C11.7324 0 8.10001 3.63235 8.10001 8.10001L8.10001 36.4501 2.43 36.4501C1.08844 36.4501 0 37.5385 0 38.8801 0 44.2463 4.35376 48.6001 9.72002 48.6001L40.5001 48.6001 40.5001 36.4501 16.2 36.4501 16.2 8.10001 56.7001 8.10001 56.7001 12.15 64.8001 12.15 64.8001 8.10001C64.8001 3.63235 61.1678 0 56.7001 0L16.2 0ZM64.8001 16.2 50.6251 16.2C47.2712 16.2 44.5501 18.9211 44.5501 22.275L44.5501 58.7251C44.5501 62.079 47.2712 64.8001 50.6251 64.8001L74.9251 64.8001C78.279 64.8001 81.0001 62.079 81.0001 58.7251L81.0001 32.4001 68.8501 32.4001C66.6099 32.4001 64.8001 30.5902 64.8001 28.35L64.8001 16.2ZM68.8501 16.2 68.8501 28.35 81.0001 28.35 68.8501 16.2Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00308 2564 865)"/></g></g></g></g></g></svg> <svg width="458" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><g transform="translate(-2493 -825)"><g><path d="M2497 896C2497 858.997 2527 829 2564 829L2885 829C2922 829 2952 858.997 2952 896L2952 896C2952 933.003 2922 963 2885 963L2564 963C2527 963 2497 933.003 2497 896Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="0.901961"/><text fill="#FFFFFF" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 2680.99 912)">在线阅读</text><g><g><g><path d="M16.2 0C11.7324 0 8.10001 3.63235 8.10001 8.10001L8.10001 36.4501 2.43 36.4501C1.08844 36.4501 0 37.5385 0 38.8801 0 44.2463 4.35376 48.6001 9.72002 48.6001L40.5001 48.6001 40.5001 36.4501 16.2 36.4501 16.2 8.10001 56.7001 8.10001 56.7001 12.15 64.8001 12.15 64.8001 8.10001C64.8001 3.63235 61.1678 0 56.7001 0L16.2 0ZM64.8001 16.2 50.6251 16.2C47.2712 16.2 44.5501 18.9211 44.5501 22.275L44.5501 58.7251C44.5501 62.079 47.2712 64.8001 50.6251 64.8001L74.9251 64.8001C78.279 64.8001 81.0001 62.079 81.0001 58.7251L81.0001 32.4001 68.8501 32.4001C66.6099 32.4001 64.8001 30.5902 64.8001 28.35L64.8001 16.2ZM68.8501 16.2 68.8501 28.35 81.0001 28.35 68.8501 16.2Z" fill="#FFFFFF" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00308 2564 865)"/></g></g></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -1 +1 @@
<svg width="458" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><defs><clipPath id="clip0"><rect x="1801" y="825" width="458" height="142"/></clipPath><clipPath id="clip1"><rect x="1801" y="825" width="458" height="142"/></clipPath></defs><g clip-path="url(#clip0)" transform="translate(-1801 -825)"><g clip-path="url(#clip1)"><path d="M1804 896C1804 858.997 1834 829 1871 829L2192 829C2229 829 2259 858.997 2259 896L2259 896C2259 933.003 2229 963 2192 963L1871 963C1834 963 1804 933.003 1804 896Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="0.901961"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1987.51 912)">在线阅读</text><g><g><g><path d="M16.2 0C11.7324 0 8.10001 3.63235 8.10001 8.10001L8.10001 36.4501 2.43 36.4501C1.08844 36.4501 0 37.5385 0 38.8801 0 44.2463 4.35376 48.6001 9.72002 48.6001L40.5001 48.6001 40.5001 36.4501 16.2 36.4501 16.2 8.10001 56.7001 8.10001 56.7001 12.15 64.8001 12.15 64.8001 8.10001C64.8001 3.63235 61.1678 0 56.7001 0L16.2 0ZM64.8001 16.2 50.6251 16.2C47.2712 16.2 44.5501 18.9211 44.5501 22.275L44.5501 58.7251C44.5501 62.079 47.2712 64.8001 50.6251 64.8001L74.9251 64.8001C78.279 64.8001 81.0001 62.079 81.0001 58.7251L81.0001 32.4001 68.8501 32.4001C66.6099 32.4001 64.8001 30.5902 64.8001 28.35L64.8001 16.2ZM68.8501 16.2 68.8501 28.35 81.0001 28.35 68.8501 16.2Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1" transform="matrix(1 0 0 1.00308 1871 865)"/></g></g></g></g></g></svg> <svg width="459" height="142" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" overflow="hidden"><defs><clipPath id="clip0"><rect x="1292" y="672" width="83" height="65"/></clipPath><clipPath id="clip1"><rect x="1292" y="672" width="83" height="65"/></clipPath><clipPath id="clip2"><rect x="1292" y="672" width="83" height="65"/></clipPath></defs><g transform="translate(-1223 -632)"><g><path d="M1227 704C1227 666.997 1257 637 1294 637L1614 637C1651 637 1681 666.997 1681 704L1681 704C1681 741.003 1651 771 1614 771L1294 771C1257 771 1227 741.003 1227 704Z" fill="#52BBB1" fill-rule="evenodd" fill-opacity="1"/><text fill="#3B3B3B" fill-opacity="1" font-family="Noto Sans SC Medium,Noto Sans SC Medium_MSFontService,sans-serif" font-style="normal" font-variant="normal" font-weight="500" font-stretch="normal" font-size="48" text-anchor="start" direction="ltr" writing-mode="lr-tb" unicode-bidi="normal" text-decoration="none" transform="matrix(1 0 0 1 1410.27 721)">在线阅读</text><g clip-path="url(#clip0)"><g clip-path="url(#clip1)"><g clip-path="url(#clip2)"><path d="M16.25 0C11.7685 0 8.125 3.64355 8.125 8.125L8.125 36.5625 2.4375 36.5625C1.0918 36.5625 0 37.6543 0 39 0 44.3828 4.36719 48.75 9.75 48.75L40.625 48.75 40.625 36.5625 16.25 36.5625 16.25 8.125 56.875 8.125 56.875 12.1875 65 12.1875 65 8.125C65 3.64355 61.3564 0 56.875 0L16.25 0ZM65 16.25 50.7812 16.25C47.417 16.25 44.6875 18.9795 44.6875 22.3437L44.6875 58.9062C44.6875 62.2705 47.417 65 50.7812 65L75.1562 65C78.5205 65 81.25 62.2705 81.25 58.9062L81.25 32.5 69.0625 32.5C66.8154 32.5 65 30.6846 65 28.4375L65 16.25ZM69.0625 16.25 69.0625 28.4375 81.25 28.4375 69.0625 16.25Z" fill="#3B3B3B" fill-rule="nonzero" fill-opacity="1" transform="matrix(1.00923 0 0 1 1293 672)"/></g></g></g></g></g></svg>

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Loading…
Cancel
Save