Data Structures & Algorithms
237 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- Subsetshistorical
Given an integer array nums whose elements are all distinct, return all possible subsets (the power set).
- 3.14 Quick Sorthistorical
Quicksort selects a pivot, moves smaller values to one side and larger values to the other, then repeats the process on each partition.
- Unique Pathshistorical
A robot starts at the top-left corner of an m × n grid and can move only down or right. Count the paths to the bottom-right corner.
- 3.15 Selection Sorthistorical
Selection sort finds the largest or smallest element on each pass and places it in position, reducing the number of swaps compared with bubble sort.
- Number of Islandshistorical
Given a 2D grid consisting of '1' (land) and '0' (water), calculate the number of islands in the grid.
- 3.16 Sortinghistorical
This page collects notes on bubble, selection, insertion, merge, quick, and heap sort, comparing their time complexity, space complexity, and stability.
- 4.1 Compare-and-Swap (CAS)historical
Compare-and-Swap (CAS): CAS (Compare-and-Swap) is an atomic operation: compare the current value in memory with an expected value, and replace it with a new value only when they match.
- Maximal Squarehistorical
In a 2D matrix consisting of '0' and '1', find the largest square containing only '1' and return its area.
- 4.2 Lock-Free Queuehistorical
A Lock-Free Queue is a thread-safe queue implemented with lock-free techniques, usually relying on CAS and other atomic operations to coordinate concurrent updates.
- Course Schedulehistorical
Given numCourses courses and their prerequisite relationships, determine whether all courses can be completed.