Skip to content

My GO solutions for daily Leetcode ✏️

License

NotificationsYou must be signed in to change notification settings

LuaanNguyen/go-leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Daily LeetCode Solutions in Go ✏️

This repository contains my solutions to LeetCode problems in Go.

Go

Folder Structure 🗂️

  • easy/: Easy level problems.
  • medium/: Medium level problems.
  • hard/: Hard level problems.

Unit Testing 🧪

In your root direction, run:

go test ./...

If you only want to run tests in a specific problem (e.g., ./easy/0001_two_sum), run:

go test ./easy/0001_two_sum

Clean test cache

go clean -testcache

Solutions (Continue Updating...)

Leetcode IDTitle & SolutionCoefficient Of DifficultyRemarksApproach
3042Count Prefix and Suffix Pairs IEasyArray String
2185Counting Words With a Given PrefixEasyArray String String Matching
1400Construct K Palindrome StringsMediumHashTable String Greedy Counting
2116Check if a Parentheses String Can Be ValidMediumStack String Greedy
3223Minimum Length of String After OperationsMediumHashTable String Counting
2657Find the Prefix Common Array of Two ArraysMediumHashTable Array
2429Minimize XORMediumBit Manipulation
2425Bitwise XOR of All PairingsMediumBit Manipulation Brain Teaser
2683Neigring Bitwise XORMediumBit Manipulation Array
1368Minimum Cost to Make at Least One Valid Path in a GridHardBreadth First Search Graph Heap(Priority Queue) Matrix Shortest Path Array
407Trapping Rain Water IIHardBreadth First Search Graph Heap(Priority Queue) Matrix Shortest Path Array
2661First Completely Painter Row or ColumnmediumMatrix HashTable Array
2017Grid GamemediumMatrix Prefix Sum
1765Map of Highest PeakmediumGraph Breadth-First Search
1267Count Servers that CommunicatemediumCounting Array
802Find Eventual Safe StatesmediumDepth-First Search Adjacency List
75Sort ColorsmediumThree Pointers DNF AlgortithmInitalize 3 pointers. Left and mid at 0, high at len(nums) - 1. Do a while loop as long as mid <= high and swap elements based on 3 conditions.
229Sort ColorsmediumCounter HashmapThere can be at most 2 such elements with floor(n /3). Do a first pass to find all and eliminate all the non-qualify elements, then the second pass check how many time a each candidate appear in the original array.
167Two Sum II - Input Array Is SortedmediumTwo PointersWe know that the array is sorted in asc order. We can track the total sum of 2 pointers left and right and increase or decrease their indices accordingly in a while loop
153SummediumTwo PointersInterate through the array, initialize 2 other pointers j = i + 1 and k = n - 1 and check the sum and adjust j and k accordingly. Make sure to check duplicates
33753SummediumHashmapThere is no solution if a value that smaller than k. If a value is larger than k, we add it to our set and count the length of the set at the end
680Valid Palindrome IIeasyTwo PointersHave a helper function which has the same structure as the main function. Use 2 pointers to check the +1 or -1 element whether they are equal or not
344Reverse StringeasyTwo Pointers
2843Count Symmetric Integerseasy
184SummediumTwo pointersDo Two Sum II and 3Sum first since 4Sum is the combination of those problems. There is an extra for loop. Make sure to check duplicates.

Workflow 🌊

  1. go.yml: This workflow runs whenver new code is pushed to main or create a pull request
  • Runs all Go tests
  • Checks code formatting with go fmt
  • Runs go vet for static analysis
  • Runs staticcheck for additional code quality checks
  1. update-stats.yml: This runs whenever you push changes to your solution directory (easy/medium/hard). It:
  • Counts the number of solutions in each level
  • Update README.md with current stats
  • Automaticall commits and pushes the changes

Statistics 📊

  • Easy: 8 solutions
  • Medium: 17 solutions
  • Hard: 2 solutions
  • Total: 27 solutions

License 🪪

MIT License
Copyright (c) 2025 Luan Nguyen