hello-algo
《Hello 算法》:动画图解、一键运行的数据结构与算法教程。支持 Python, Java, C++, C, C#, JS, Go, Swift, Rust, Ruby, Kotlin, TS, Dart 代码。简体版和繁体版同步更新,English version ongoing
Top Related Projects
All Algorithms implemented in Python
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
A curated list of awesome Go frameworks, libraries and software
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
🌍 针对小白的算法训练 | 包括四部分:①.大厂面经 ②.力扣图解 ③.千本开源电子书 ④.百张技术思维导图(项目花了上百小时,希望可以点 star 支持,🌹感谢~)推荐免费ChatGPT使用网站
刷算法全靠套路,认准 labuladong 就够了!English version supported! Crack LeetCode, not only how, but also why.
Quick Overview
"Hello, Algorithm" is an open-source project aimed at providing a comprehensive introduction to data structures and algorithms. It offers detailed explanations, illustrations, and code implementations in multiple programming languages, making it an excellent resource for both beginners and those looking to refresh their knowledge.
Pros
- Covers a wide range of data structures and algorithms with clear explanations
- Provides implementations in multiple programming languages (Java, C++, Python, Go, JS, TS, C#, Swift, Rust, Dart)
- Includes visualizations and animations to aid understanding
- Regularly updated and maintained with contributions from the community
Cons
- May be overwhelming for absolute beginners due to the breadth of content
- Some advanced topics might not be covered in as much depth as specialized resources
- Code examples might not always follow best practices or optimizations for specific languages
Code Examples
# Example of binary search implementation
def binary_search(nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] < target:
left = mid + 1
elif nums[mid] > target:
right = mid - 1
else:
return mid
return -1
// Example of a singly linked list node
class ListNode {
int val;
ListNode next;
ListNode(int x) { val = x; }
}
// Example of bubble sort implementation
function bubbleSort(nums) {
for (let i = nums.length - 1; i > 0; i--) {
for (let j = 0; j < i; j++) {
if (nums[j] > nums[j + 1]) {
[nums[j], nums[j + 1]] = [nums[j + 1], nums[j]];
}
}
}
return nums;
}
Getting Started
To get started with the "Hello, Algorithm" project:
- Visit the GitHub repository: https://github.com/krahets/hello-algo
- Choose your preferred programming language from the available options
- Navigate through the chapters and topics in the README or the provided documentation
- Clone the repository to access code examples locally:
git clone https://github.com/krahets/hello-algo.git
- Explore the code implementations and explanations for various data structures and algorithms
Competitor Comparisons
All Algorithms implemented in Python
Pros of Python
- Extensive collection of algorithms covering various domains
- Well-organized structure with algorithms categorized by type
- Large community of contributors and active maintenance
Cons of Python
- Lacks comprehensive explanations or tutorials for each algorithm
- May be overwhelming for beginners due to the vast number of algorithms
- Some implementations may prioritize correctness over optimization
Code Comparison
hello-algo (Binary Search implementation in Python):
def binary_search(nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] < target:
left = mid + 1
elif nums[mid] > target:
right = mid - 1
else:
return mid
return -1
Python (Binary Search implementation):
def binary_search(arr, x):
low = 0
high = len(arr) - 1
while low <= high:
mid = (high + low) // 2
if arr[mid] < x:
low = mid + 1
elif arr[mid] > x:
high = mid - 1
else:
return mid
return -1
Both implementations are similar, with hello-algo using type hints and slightly different variable names.
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
Pros of javascript-algorithms
- Extensive collection of algorithms and data structures implemented in JavaScript
- Well-organized with detailed explanations and complexity analysis for each algorithm
- Includes unit tests for most implementations, ensuring code reliability
Cons of javascript-algorithms
- Focuses solely on JavaScript, limiting its usefulness for developers working in other languages
- May be overwhelming for beginners due to its comprehensive nature and advanced topics
- Less emphasis on visual explanations and step-by-step learning compared to hello-algo
Code Comparison
hello-algo (Python implementation of binary search):
def binary_search(nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] < target:
left = mid + 1
elif nums[mid] > target:
right = mid - 1
else:
return mid
return -1
javascript-algorithms (JavaScript implementation of binary search):
function binarySearch(array, item) {
let start = 0;
let end = array.length - 1;
while (start <= end) {
const middle = Math.floor((start + end) / 2);
if (array[middle] === item) {
return middle;
}
if (item < array[middle]) {
end = middle - 1;
} else {
start = middle + 1;
}
}
return -1;
}
Both implementations follow similar logic, but hello-algo uses Python while javascript-algorithms uses JavaScript. The main differences are in syntax and variable naming conventions.
A curated list of awesome Go frameworks, libraries and software
Pros of awesome-go
- Comprehensive collection of Go resources, libraries, and tools
- Well-organized and categorized for easy navigation
- Regularly updated with community contributions
Cons of awesome-go
- Lacks in-depth explanations or tutorials for listed resources
- May overwhelm beginners with the sheer volume of information
Code comparison
Not applicable, as awesome-go is a curated list of resources and doesn't contain code examples. hello-algo, on the other hand, provides code implementations of algorithms in multiple programming languages.
hello-algo example (Python):
def bubble_sort(nums):
for i in range(len(nums) - 1):
for j in range(len(nums) - 1 - i):
if nums[j] > nums[j + 1]:
nums[j], nums[j + 1] = nums[j + 1], nums[j]
return nums
Summary
awesome-go serves as an extensive directory of Go-related resources, making it an invaluable reference for developers at all levels. However, it doesn't provide detailed explanations or implementations like hello-algo does. hello-algo focuses on teaching algorithms with code examples in multiple languages, offering a more educational approach for those looking to learn specific algorithms and data structures.
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
Pros of system-design-primer
- Comprehensive coverage of system design concepts and principles
- Includes real-world examples and case studies from large-scale systems
- Provides a structured learning path with additional resources and references
Cons of system-design-primer
- Focuses primarily on high-level system design, with less emphasis on algorithm implementation
- May be overwhelming for beginners due to its extensive content and advanced topics
- Less hands-on coding practice compared to hello-algo
Code comparison
hello-algo:
def bubble_sort(nums):
for i in range(len(nums) - 1):
for j in range(len(nums) - 1 - i):
if nums[j] > nums[j + 1]:
nums[j], nums[j + 1] = nums[j + 1], nums[j]
system-design-primer:
class Cache:
def __init__(self, MAX_SIZE):
self.MAX_SIZE = MAX_SIZE
self.size = 0
self.lookup = {}
self.linked_list = LinkedList()
Summary
system-design-primer is a comprehensive resource for learning system design concepts, offering real-world examples and a structured learning path. It excels in covering high-level design principles but may be challenging for beginners. hello-algo, on the other hand, focuses more on algorithm implementation and provides hands-on coding practice. The code comparison shows that hello-algo emphasizes algorithm implementation, while system-design-primer includes more abstract system components.
🌍 针对小白的算法训练 | 包括四部分:①.大厂面经 ②.力扣图解 ③.千本开源电子书 ④.百张技术思维导图(项目 花了上百小时,希望可以点 star 支持,🌹感谢~)推荐免费ChatGPT使用网站
Pros of hello-algorithm
- Covers a wider range of algorithms and data structures
- Includes more detailed explanations and visualizations
- Offers solutions in multiple programming languages
Cons of hello-algorithm
- Less frequently updated compared to hello-algo
- May be overwhelming for beginners due to the extensive content
- Repository structure is less organized
Code Comparison
hello-algorithm (Python):
def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
hello-algo (Python):
def binary_search(nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] < target:
left = mid + 1
elif nums[mid] > target:
right = mid - 1
else:
return mid
return -1
Both repositories provide implementations of common algorithms, but hello-algo focuses on a more structured approach with cleaner code and better organization. hello-algorithm offers a broader range of topics and multiple language implementations, making it suitable for those seeking comprehensive coverage. However, hello-algo's frequent updates and beginner-friendly approach make it more accessible for those starting their journey in algorithms and data structures.
刷算法全靠套路,认准 labuladong 就够了!English version supported! Crack LeetCode, not only how, but also why.
Pros of fucking-algorithm
- More comprehensive coverage of advanced algorithms and data structures
- In-depth explanations and analysis of problem-solving techniques
- Includes solutions in multiple programming languages
Cons of fucking-algorithm
- Less beginner-friendly, assumes prior knowledge of basic algorithms
- Lacks visual aids and illustrations for complex concepts
- Updates less frequently compared to hello-algo
Code Comparison
hello-algo (Python):
def binary_search(nums: List[int], target: int) -> int:
left, right = 0, len(nums) - 1
while left <= right:
mid = left + (right - left) // 2
if nums[mid] < target:
left = mid + 1
elif nums[mid] > target:
right = mid - 1
else:
return mid
return -1
fucking-algorithm (Java):
int binarySearch(int[] nums, int target) {
int left = 0, right = nums.length - 1;
while(left <= right) {
int mid = left + (right - left) / 2;
if (nums[mid] == target)
return mid;
else if (nums[mid] < target)
left = mid + 1;
else if (nums[mid] > target)
right = mid - 1;
}
return -1;
}
Both repositories offer valuable resources for learning algorithms, with hello-algo focusing on beginners and fucking-algorithm catering to more advanced learners. The code comparison shows similar implementations of binary search, with minor differences in language-specific syntax.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
å¨ç»å¾è§£ãä¸é®è¿è¡çæ°æ®ç»æä¸ç®æ³æç¨
ç®ä½ä¸æ ï½ ç¹é«ä¸æ ï½ English
å ³äºæ¬ä¹¦
æ¬é¡¹ç®æ¨å¨æé ä¸æ¬å¼æºå è´¹ãæ°æå好çæ°æ®ç»æä¸ç®æ³å ¥é¨æç¨ã
- å ¨ä¹¦éç¨å¨ç»å¾è§£ï¼å å®¹æ¸ æ°ææãå¦ä¹ æ²çº¿å¹³æ»ï¼å¼å¯¼åå¦è æ¢ç´¢æ°æ®ç»æä¸ç®æ³çç¥è¯å°å¾ã
- æºä»£ç å¯ä¸é®è¿è¡ï¼å¸®å©è¯»è å¨ç»ä¹ ä¸æåç¼ç¨æè½ï¼äºè§£ç®æ³å·¥ä½åçåæ°æ®ç»æåºå±å®ç°ã
- æå¡è¯»è äºå©å¦ä¹ ï¼æ¬¢è¿å¤§å®¶å¨è¯è®ºåºæåºé®é¢ä¸å享è§è§£ï¼å¨äº¤æµè®¨è®ºä¸å ±åè¿æ¥ã
è¥æ¬ä¹¦å¯¹æ¨ææ帮å©ï¼è¯·å¨é¡µé¢å³ä¸è§ç¹ä¸ª Star :star: æ¯æä¸ä¸ï¼è°¢è°¢ï¼
æ¨èè¯
âä¸æ¬éä¿ææçæ°æ®ç»æä¸ç®æ³å ¥é¨ä¹¦ï¼å¼å¯¼è¯»è æè并ç¨å°å¦ä¹ ï¼å¼ºçæ¨èç®æ³åå¦è é 读ãâ
ââ éä¿è¾ï¼æ¸ å大å¦è®¡ç®æºç³»ææ
âå¦ææå½å¹´å¦æ°æ®ç»æä¸ç®æ³çæ¶åæãHello ç®æ³ãï¼å¦èµ·æ¥åºè¯¥ä¼ç®å 10 åï¼â
ââ ææ²ï¼äºé©¬éèµæ·±é¦å¸ç§å¦å®¶
è´¡ç®
æ¬å¼æºä¹¦ä»å¨æç»æ´æ°ä¹ä¸ï¼æ¬¢è¿æ¨åä¸æ¬é¡¹ç®ï¼ä¸å为读è æä¾æ´ä¼è´¨çå¦ä¹ å 容ã
- å 容修æ£ï¼è¯·æ¨åå©ä¿®æ£æå¨è¯è®ºåºæåºè¯æ³é误ãå 容缺失ãæåæ§ä¹ãæ æé¾æ¥æ代ç bug çé®é¢ã
- 代ç 转è¯ï¼æå¾ æ¨è´¡ç®åç§è¯è¨ä»£ç ï¼å·²æ¯æ PythonãJavaãC++ãGoãJavaScript ç 12 é¨ç¼ç¨è¯è¨ã
- ä¸è¯è±ï¼è¯éæ¨å å ¥æ们çç¿»è¯å°ç»ï¼æå主è¦æ¥èªè®¡ç®æºç¸å ³ä¸ä¸ãè±è¯ä¸ä¸åè±ææ¯è¯è ã
欢è¿æ¨æåºå®è´µæè§å建议ï¼å¦æä»»ä½é®é¢è¯·æ交 Issues æ微信èç³» krahets-jyd
ã
æè°¢æ¬å¼æºä¹¦çæ¯ä¸ä½æ°ç¨¿äººï¼æ¯ä»ä»¬çæ ç§å¥ç®è®©è¿æ¬ä¹¦åå¾æ´å¥½ï¼ä»ä»¬æ¯ï¼
License
The texts, code, images, photos, and videos in this repository are licensed under CC BY-NC-SA 4.0.
Top Related Projects
All Algorithms implemented in Python
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
A curated list of awesome Go frameworks, libraries and software
Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.
🌍 针对小白的算法训练 | 包括四部分:①.大厂面经 ②.力扣图解 ③.千本开源电子书 ④.百张技术思维导图(项目花了上百小时,希望可以点 star 支持,🌹感谢~)推荐免费ChatGPT使用网站
刷算法全靠套路,认准 labuladong 就够了!English version supported! Crack LeetCode, not only how, but also why.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot