Convert Figma logo to code with AI

krahets logohello-algo

《Hello 算法》:动画图解、一键运行的数据结构与算法教程。支持 Python, Java, C++, C, C#, JS, Go, Swift, Rust, Ruby, Kotlin, TS, Dart 代码。简体版和繁体版同步更新,English version ongoing

96,941
12,295
96,941
16

Top Related Projects

191,495

All Algorithms implemented in Python

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings

130,604

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:

  1. Visit the GitHub repository: https://github.com/krahets/hello-algo
  2. Choose your preferred programming language from the available options
  3. Navigate through the chapters and topics in the README or the provided documentation
  4. Clone the repository to access code examples locally:
    git clone https://github.com/krahets/hello-algo.git
    
  5. Explore the code implementations and explanations for various data structures and algorithms

Competitor Comparisons

191,495

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.

130,604

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 Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

hello-algo-typing-svg
动画图解、一键运行的数据结构与算法教程

简体中文 | 繁體中文 | 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.