Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Algorithms

My LeetCode / HackerRank practice in Go.

Layout

fundamentals/          classic algorithms & data structures, learned on their own
  sorting/             bubble, insertion, selection, merge, quick
leetcode/
  0003-<slug>/         one folder per problem, zero-padded number + LeetCode slug
    README.md          link, difficulty, pattern, complexity, notes
    solution.go        LeetCode's Go starter code (paste-ready)
    solution_test.go   table-driven tests, pre-filled with LeetCode's examples
    types.go           ListNode / TreeNode + helpers, when the problem uses them
hackerrank/
  <slug>/
    solution.go        HackerRank's full Go program (package main, paste-ready)
    solution_test.go   runs main on every testdata/inputNN.txt
    testdata/          sample inputNN.txt / outputNN.txt
scripts/new.sh         scaffold a new problem folder (see scripts/newproblem)
scripts/submit.sh      test a LeetCode solution, then submit it if the tests pass
images/                diagrams used in notes

Each LeetCode folder is its own package problem, so solutions never collide and helpers can be copied freely between them.

Workflow

scripts/new.sh leetcode two-sum            # -> leetcode/0001-two-sum/
scripts/new.sh leetcode https://leetcode.com/problems/two-sum/
scripts/new.sh hackerrank mini-max-sum     # -> hackerrank/mini-max-sum/

go test ./leetcode/0001-two-sum/           # run one problem
go test ./...                              # run everything

scripts/submit.sh 1                        # test, then submit if green

new.sh downloads the starter code and example test cases. A new stub panics with "not implemented" until you write the solution. For design problems (e.g. Min Stack) and problems with hidden inputs (e.g. Linked List Cycle), the examples are left as comments in a skipped test to fill in by hand. For HackerRank, extra downloaded test cases can go straight into testdata/. Offline, scripts/new.sh leetcode <number> <slug> creates a blank template.

submit.sh takes a folder, number or slug. It runs the folder's tests and submits solution.go only if they all pass (skipped or missing tests count as not passing), then prints the verdict: runtime and memory percentiles, or the failing input to add to solution_test.go. It uses your leetcode.com login: copy the LEETCODE_SESSION and csrftoken cookies from a logged-in browser tab (DevTools > Application > Cookies) into LEETCODE_SESSION and LEETCODE_CSRF_TOKEN. They expire every few weeks.

Index

# Problem Difficulty Pattern
3 Longest Substring Without Repeating Characters Medium Sliding window
283 Move Zeroes Easy Two pointers

About

A collection of algorithms and data structures implemented to explore problem-solving, optimization, and computational thinking.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages