Skip to content
Data structures & algorithms cheat sheet
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
binary_search.md
dynamic_programming.md
minimum_spanning_tree.md
shortest_path.md
sorting.md
stack_queue.md

README.md

cheat-sheet

Warning: Copying and pasting code from this cheat sheet for a programming competition will cause you to fail the plagiarism detector.

This cheat sheet contains concise implementations of common data structures and algorithms (DS&As) in Python. Its purpose is to give you a short list of DS&As that are worth memorizing because they are frequently used, yet most people struggle with them. I have excluded DS&As that most computer science graduates can implement with very little thought, such as tree traversals.

Table of Contents

Sorting

  • Quickselect
  • Radix Sort

Binary Search

  • Index of First True

Stacks and Queues

  • All Nearest Smaller Values
  • String Parsing

Bit Manipulation

  • Single Number

Dynamic Programming

  • Longest Common Subsequence
  • Knapsack Problem
  • Best Time to Buy and Sell Stock
  • Matrix Chain Multiplication

Shortest Path Algorithms

  • Djikstra's Algorithm
  • Bellman-Ford Algorithm
  • Floyd-Warshall Algorithm

Competitive Programming Hacks

  • Fast O(n) Tricks
  • 2-Line Memoization
You can’t perform that action at this time.