Convert Figma logo to code with AI

6boris logoawesome-golang-algorithm

:memo: LeetCode of algorithms with golang solution(updating).

3,483
185
3,483
3

Top Related Projects

✅ Solutions to LeetCode by Go, 100% test coverage, runtime beats 100% / LeetCode 题解

128,386

A curated list of awesome Go frameworks, libraries and software

18,744

❤️ 1000+ Hand-Crafted Go Examples, Exercises, and Quizzes. 🚀 Learn Go by fixing 1000+ tiny programs.

Curated list of Go design patterns, recipes and idioms

15,801

Algorithms and Data Structures implemented in Go for beginners, following best practices.

:memo: LeetCode of algorithms with golang solution(updating).

Quick Overview

The 6boris/awesome-golang-algorithm repository is a curated collection of algorithms and data structures implemented in Go. It serves as a comprehensive resource for developers looking to learn, practice, or reference various algorithmic solutions in the Go programming language.

Pros

  • Extensive collection of algorithms covering a wide range of topics
  • Well-organized structure with clear categorization of algorithms
  • Includes solutions for popular coding platforms like LeetCode and HackerRank
  • Actively maintained with regular contributions and updates

Cons

  • Some implementations may lack detailed explanations or comments
  • Not all algorithms have accompanying test cases
  • The repository structure might be overwhelming for beginners
  • Some advanced algorithms or data structures may be missing

Code Examples

Here are a few examples of algorithms implemented in this repository:

  1. Binary Search
func binarySearch(arr []int, target int) int {
    left, right := 0, len(arr)-1
    for left <= right {
        mid := left + (right-left)/2
        if arr[mid] == target {
            return mid
        } else if arr[mid] < target {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
    return -1
}
  1. Quick Sort
func quickSort(arr []int) []int {
    if len(arr) <= 1 {
        return arr
    }
    pivot := arr[len(arr)/2]
    left := make([]int, 0)
    right := make([]int, 0)
    for i := 0; i < len(arr); i++ {
        if i == len(arr)/2 {
            continue
        }
        if arr[i] < pivot {
            left = append(left, arr[i])
        } else {
            right = append(right, arr[i])
        }
    }
    return append(append(quickSort(left), pivot), quickSort(right)...)
}
  1. Depth-First Search (DFS)
func dfs(graph map[int][]int, start int, visited map[int]bool) {
    if visited[start] {
        return
    }
    visited[start] = true
    fmt.Printf("%d ", start)
    for _, neighbor := range graph[start] {
        dfs(graph, neighbor, visited)
    }
}

Getting Started

To use the algorithms in this repository:

  1. Clone the repository:

    git clone https://github.com/6boris/awesome-golang-algorithm.git
    
  2. Navigate to the desired algorithm's directory.

  3. Import the algorithm in your Go code:

    import "path/to/algorithm"
    
  4. Use the implemented functions in your code as needed.

Competitor Comparisons

✅ Solutions to LeetCode by Go, 100% test coverage, runtime beats 100% / LeetCode 题解

Pros of LeetCode-Go

  • More comprehensive coverage of LeetCode problems
  • Detailed explanations and comments for each solution
  • Well-organized structure with problems categorized by difficulty and topic

Cons of LeetCode-Go

  • Focused solely on LeetCode problems, lacking broader algorithm coverage
  • May not include as many advanced or specialized algorithms
  • Less frequent updates compared to awesome-golang-algorithm

Code Comparison

LeetCode-Go:

func twoSum(nums []int, target int) []int {
    m := make(map[int]int)
    for i, num := range nums {
        if j, ok := m[target-num]; ok {
            return []int{j, i}
        }
        m[num] = i
    }
    return nil
}

awesome-golang-algorithm:

func twoSum(nums []int, target int) []int {
    for i := 0; i < len(nums); i++ {
        for j := i + 1; j < len(nums); j++ {
            if nums[i]+nums[j] == target {
                return []int{i, j}
            }
        }
    }
    return nil
}

The LeetCode-Go solution uses a hash map for O(n) time complexity, while the awesome-golang-algorithm solution uses a nested loop with O(n^2) time complexity. This demonstrates the focus on optimized solutions in LeetCode-Go, whereas awesome-golang-algorithm may prioritize simplicity and readability in some cases.

128,386

A curated list of awesome Go frameworks, libraries and software

Pros of awesome-go

  • Much larger and more comprehensive collection of Go resources
  • Better organized with clear categories and subcategories
  • More frequently updated and maintained

Cons of awesome-go

  • Can be overwhelming due to the sheer volume of resources
  • Less focused on algorithms specifically

Code comparison

Not applicable for these repositories, as they are curated lists of resources rather than code repositories.

Key differences

awesome-golang-algorithm:

  • Focused specifically on algorithms and data structures
  • Includes implementation examples
  • Smaller, more manageable list

awesome-go:

  • Covers a wide range of Go-related topics and resources
  • Includes libraries, frameworks, and tools
  • Larger community and more contributors

Use cases

awesome-golang-algorithm:

  • Ideal for developers looking to study and implement algorithms in Go
  • Useful for interview preparation and algorithm practice

awesome-go:

  • Better for developers seeking a comprehensive overview of the Go ecosystem
  • Valuable for finding tools and libraries for various Go projects

Community and maintenance

awesome-go:

  • Larger community with more frequent updates
  • More contributors and stars on GitHub

awesome-golang-algorithm:

  • Smaller community but still actively maintained
  • More focused scope allows for easier contribution in the algorithm domain
18,744

❤️ 1000+ Hand-Crafted Go Examples, Exercises, and Quizzes. 🚀 Learn Go by fixing 1000+ tiny programs.

Pros of learngo

  • Comprehensive learning resource with structured tutorials and exercises
  • Includes hands-on projects and quizzes for practical learning
  • Regularly updated with new content and improvements

Cons of learngo

  • Focused on learning Go, not specifically on algorithms
  • May not cover advanced algorithmic concepts in depth
  • Less curated collection of external resources compared to awesome-golang-algorithm

Code Comparison

learngo example (basic syntax):

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

awesome-golang-algorithm example (algorithm implementation):

func twoSum(nums []int, target int) []int {
    m := make(map[int]int)
    for i, num := range nums {
        if j, ok := m[target-num]; ok {
            return []int{j, i}
        }
        m[num] = i
    }
    return nil
}

Summary

learngo is an excellent resource for beginners learning Go programming, offering structured tutorials and hands-on exercises. awesome-golang-algorithm, on the other hand, is a curated list of Go algorithm implementations and resources, making it more suitable for those specifically interested in algorithmic problem-solving in Go. While learngo provides a comprehensive learning path for Go beginners, awesome-golang-algorithm offers a focused collection of algorithmic content for more advanced users or those specifically interested in algorithms.

Curated list of Go design patterns, recipes and idioms

Pros of go-patterns

  • Focuses on design patterns and idiomatic Go code structures
  • Provides explanations and use cases for each pattern
  • Includes visual diagrams for better understanding

Cons of go-patterns

  • Less comprehensive in terms of algorithm coverage
  • Not actively maintained (last update was several years ago)
  • Lacks practical examples for some patterns

Code Comparison

go-patterns (Singleton pattern):

type singleton struct {}

var instance *singleton
var once sync.Once

func GetInstance() *singleton {
    once.Do(func() {
        instance = &singleton{}
    })
    return instance
}

awesome-golang-algorithm (Binary Search implementation):

func BinarySearch(arr []int, target int) int {
    left, right := 0, len(arr)-1
    for left <= right {
        mid := left + (right-left)/2
        if arr[mid] == target {
            return mid
        } else if arr[mid] < target {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
    return -1
}

Summary

go-patterns focuses on design patterns and idiomatic Go code structures, providing explanations and visual diagrams. However, it lacks comprehensive algorithm coverage and recent updates. awesome-golang-algorithm offers a wider range of algorithms and data structures with practical implementations, making it more suitable for algorithm-focused learning and problem-solving in Go.

15,801

Algorithms and Data Structures implemented in Go for beginners, following best practices.

Pros of Go

  • More comprehensive collection of algorithms and data structures
  • Better organized with clear directory structure
  • Includes unit tests for most implementations

Cons of Go

  • Less focused on Golang-specific optimizations
  • Fewer advanced or specialized algorithms
  • May be overwhelming for beginners due to its extensive collection

Code Comparison

awesome-golang-algorithm (Binary Search implementation):

func binarySearch(arr []int, target int) int {
    left, right := 0, len(arr)-1
    for left <= right {
        mid := left + (right-left)/2
        if arr[mid] == target {
            return mid
        } else if arr[mid] < target {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
    return -1
}

Go (Binary Search implementation):

func BinarySearch(array []int, target int) int {
    left, right := 0, len(array)-1
    for left <= right {
        middle := (left + right) / 2
        if array[middle] == target {
            return middle
        } else if array[middle] > target {
            right = middle - 1
        } else {
            left = middle + 1
        }
    }
    return -1
}

Both implementations are similar, with minor differences in variable naming and calculation of the middle index. The Go repository tends to use more descriptive variable names and follows Go naming conventions more strictly.

:memo: LeetCode of algorithms with golang solution(updating).

Pros of awesome-golang-algorithm

  • Comprehensive collection of Go algorithms and data structures
  • Well-organized with clear categorization
  • Regular updates and contributions from the community

Cons of awesome-golang-algorithm

  • May lack detailed explanations for some algorithms
  • Could benefit from more real-world application examples
  • Some implementations might not be optimized for performance

Code comparison

As both repositories refer to the same project, there is no code comparison to be made. The awesome-golang-algorithm repository contains various algorithm implementations in Go. Here's a sample of a binary search implementation from the repository:

func binarySearch(arr []int, target int) int {
    left, right := 0, len(arr)-1
    for left <= right {
        mid := left + (right-left)/2
        if arr[mid] == target {
            return mid
        } else if arr[mid] < target {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
    return -1
}

This repository serves as a valuable resource for developers looking to learn and implement various algorithms in Go. It provides a centralized location for algorithm implementations, making it easier for developers to find and study different algorithmic solutions.

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


Logo

Awesome Golang Algorithm

Solutions of algorithm problems on some platforms LeetCode`, `Sword Finger Offer`.
Explore the docs »

Report Bug · Pull Request

Build Status Codecov Codecov Codecov Codecov

Introduction

Content

Community

  • LeetCode in Go Powerful and comprehensive leetcode solutions :laughing:
  • WANG leetcode The Leetcode solution of a friend. Update frequently and explain in place.
  • LeetCode-in-Go Golang problem solution of a certain algorithm boss
  • ACWING The platforms created by some algorithmic contestants are quite suitable for getting started.

Contributors

Thanks goes to these wonderful people (emoji key):


Kyle Liu

🧑‍🏫 💻 🎨 📖

hapiman2

💻

Inori

💻

hiepndd

💻

McKinnon

💻

Shuo

💻

sihg yu

💻

Coco

💻

plusweiwei

💻

ghost123gg

💻

go-ky

💻

bumblebee

💻

cheng qianxiang

💻

vortex-17

💻