Skip to content

ceezyyy/leetcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode

Study notes for data structures & algorithms

Data Structures

Array

Rotate

  1. 逆推
  2. Reverse
  3. Swap (主对角线, 分界线, 轴)

Linked List

常规手段

  • dummy 作哨兵, cur 作游标
  • 一直遍历(最长链表), 每次遍历再进行空值判断

Reverse list

  • pre, cur, post

Tree

Root-to-leaf

  • int: a + b (choose a non-empty element between a and b)
  • boolean: false (if root is null)
  • void: return

Whether the node is empty

  • (root) ? null : root

Stack and Queue

Circular Queue

  • 根据 headsize 计算出 tail
  • 循环: 对 n 取模

Hashtable

Two Sum

  • 需要频繁访问 target 时,考虑采用哈希表

String

KMP

Graph

Bit Manipulation

Algorithms

Two Pointers

Two Sum

  • 返回的是元素而非 index,可考虑排序 + 双指针

Sorting

Greedy

Binary Seach

Divide and Conquer

Searching

Dynamic Programming

Math

Add two numbers

  • reverse
  • carry : sum / n (n 进制)
  • pop : sum % n (n 进制)

Missing number

  • Gauss' Formula

About

Legacy code examples for data structures and algorithms

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published