Skip to content

A collection of LeetCode problems, data-structures and algorithms in Go following the TDD cycle.

Notifications You must be signed in to change notification settings

ggcr/go-algorithms

Repository files navigation

go-algorithms

This is a collection of algorithms and data-structure implemenetations in Go and Python made by myself!

How this works

I work with a TDD methodology. Each folder has its [name].go file and its [name]_test.go file. In order to run the go code just go to the desired path and run the following command:

go test [-v] // The -v flag is optional

Data Structures

Algorithms

Neet-Code 150

Arrays & Hashing

Two Pointers

  • Valid Palindrome (Leetcode 125): O(N) efficient solution, working with Go strings, runes or bytes is always a pleasure for its standard lib! Faster than 100% ⭐.
  • Two Sum II (Leetcode 167): O(N^2) brute force solution and O(N) efficient solution, because the array is sorted we don't need the hashmap approach.
  • 3Sum (Leetcode 15): O(N^3) brute force solution and O(N^2) Better approach in which we avoid duplicates by sorting the array and not using as first value (i) twice the same value. Then we reduce the rest of the two nums to a two sum problem.
  • Container With Most Water (Leetcode 11): O(N) time. It's not a hard problem it just requires problem specification.
  • Trapping Rain Water (Leetcode 42): O(NlogN) Approach based on finding local max "valleys", minimum of 3 numbers where the extremas are bigger than the inner numbers.

Sliding Window

Stack

Binary Search

Other

About

A collection of LeetCode problems, data-structures and algorithms in Go following the TDD cycle.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published