Skip to content

palemoky/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Solutions

Test

Computer science is no more about computers than astronomy is about telescopes. — E. W. Dijkstra

Contents

Welcome! This repository contains my solutions to LeetCode problems, implemented in Go and Python.

Each problem is organized by language and directory. Solutions include clean code, unit tests, and concise explanations where appropriate.

Directory Structure

  • 📂 go/ — Go solutions
  • 📂 python/ — Python solutions

Feel free to explore, learn, and discuss. Contributions and suggestions are always welcome!


Essential Algorithm Fundamentals

Algorithm Basics You Must Master:

  1. Linked List: traversal, reversal, merging, cycle detection
  2. Binary Tree: level order(max/min depth, symmetric tree), preorder/inorder/postorder traversal (both recursive and iterative), inversion, lowest common ancestor, merge two binary trees
  3. Sorting: quick sort, merge sort, insertion sort, selection sort, bubble sort, heap sort
  4. Binary Search: on sorted arrays, binary trees
  5. Bit Manipulation Techniques:
    • XOR (^): find numbers that appear only once or twice.
    • AND (&):
      • n & (n-1): removes the lowest set bit, commonly used to check if a number is a power of 2.
      • n & -n: gets the lowest set bit.
    • << and >>: efficient multiplication and division by 2.
    • Use XOR to find the unique unpaired number.
  6. Math Techniques: fast exponentiation, GCD/LCM, elementary math simulation

Core Algorithm Ideas:

  1. Hash table: trading space for time
  2. Two pointers: fast/slow pointers, left/right pointers (collision pointers), sliding window
  3. DFS: using a stack
  4. BFS/backtracking: using a queue
  5. Dynamic Programming (DP)

Must-Know Classic LeetCode Problems by Category

  1. Arrays & Strings
  1. Linked Lists
  1. Stacks & Queues
  1. Hash Tables
  1. Binary Search
  1. Dynamic Programming
  1. Backtracking
  1. Trees & Recursion
  1. Graphs (BFS & DFS)
  1. Greedy Algorithms
  1. Math & Bit Manipulation

Visualization Algorithm Tools

Algorithm Learning Resources

Todo List

  • 中英双语文档
  • 每个题目分析平均、最好、最坏时间复杂度
  • 每个题目分析不同解法的优缺点
  • 使用 Python 求解

About

🥷 LeetCode Solutions in Go, Python, and Rust

Topics

Resources

Stars

Watchers

Forks