알고리즘 문제 풀이
대표 문제 645개를 코드와 함께 단계별로 따라가며 풉니다. 코드의 어느 줄이 지금 도는지, 그때 자료구조가 어떻게 변하는지 나란히 봅니다.
코드 라인과 단계 ID를 동기화하고, 변수/포인터/배열·행렬·그래프 엔티티의 상태 스냅샷을 단계마다 갱신한다.
645개
Pattern Printing12개
Sorting12개
Array27개
- 쉬움Move Zeroes
- 쉬움Majority Element
- 쉬움Remove Duplicates from Sorted Array
- 쉬움Best Time to Buy and Sell Stock
- 쉬움Rotate Array
- 쉬움Product of Array Except Self
- 쉬움Best Time to Buy and Sell Stock II
- 쉬움Number of Zero-Filled Subarrays
- 쉬움Increasing Triplet Subsequence
- 쉬움First Missing Positive
- 쉬움Apple Redistribution into Boxes
- 쉬움Contains Duplicate
- 쉬움Contains Duplicate III
- 쉬움Count Binary Substrings
- 쉬움Find All Numbers Disappeared in an Array
- 쉬움Majority Element II
- 쉬움Max Consecutive Ones
- 쉬움Maximum Swap
- 쉬움Missing Number
- 쉬움Missing Ranges
- 쉬움Remove Element
- 쉬움Set Mismatch
- 쉬움Shuffle the Array
- 쉬움Shortest Unsorted Continuous Subarray
- 쉬움Summary Ranges
- 쉬움Third Maximum Number
- 쉬움Mo's Algorithm
String31개
- 쉬움Is Subsequence
- 쉬움Valid Palindrome
- 쉬움Longest Common Prefix
- 쉬움Zigzag Conversion
- 쉬움Reverse Words in a String
- 쉬움Repeated Substring Pattern
- 쉬움Repeated String Match
- 쉬움Number of Distinct Substrings in a String
- 쉬움Longest Happy Prefix
- 쉬움Shortest Palindrome
- 쉬움Longest Duplicate Substring
- 쉬움Add Bold Tag in String
- 쉬움Count and Say
- 쉬움Encode and Decode Strings
- 쉬움Find the Length of the Longest Common Prefix
- 쉬움Guess the Word
- 쉬움Integer to English Words
- 쉬움KMP Algorithm
- 쉬움Length of Last Word
- 쉬움Longest Nice Substring
- 쉬움Number of Matching Subsequences
- 쉬움One Edit Distance
- 쉬움Palindrome Pairs
- 쉬움Rabin-Karp String Search
- 쉬움Rotate String
- 쉬움Special Binary String
- 쉬움String Compression
- 쉬움Text Justification
- 쉬움Valid Word Abbreviation
- 쉬움Words Within Two Edits of Dictionary
- 쉬움Z Algorithm
Bit Manipulation9개
Hash Table21개
- 쉬움Ransom Note
- 쉬움Number of Good Pairs
- 쉬움Maximum Number of Balloons
- 쉬움Contains Duplicate II
- 쉬움Isomorphic Strings
- 쉬움Group Anagrams
- 쉬움Reorganize String
- 쉬움Longest Consecutive Sequence
- 쉬움Number of Good Ways to Split a String
- 쉬움Two Sum
- 쉬움Determine if Two Strings Are Close
- 쉬움Encode and Decode TinyURL
- 쉬움First Unique Character in a String
- 쉬움Group Shifted Strings
- 쉬움Happy Number
- 쉬움Insert Delete GetRandom O(1)
- 쉬움Longest Palindrome
- 쉬움Valid Anagram
- 쉬움Word Pattern
- 쉬움Design HashMap
- 쉬움Intersection of Two Arrays II
Two Pointers12개
Prefix Sum9개
Sliding Window27개
- 보통Maximum Average Subarray I
- 보통Permutation in String
- 보통Find All Anagrams in a String
- 보통Minimum Size Subarray Sum
- 보통Max Consecutive Ones III
- 보통Longest Substring Without Repeating Characters
- 보통Minimum Window Substring
- 보통Continuous Subarrays
- 보통Count Number of Nice Subarrays
- 보통Count Subarrays With Fixed Bounds
- 보통Frequency of the Most Frequent Element
- 보통Fruit Into Baskets
- 보통Longest Repeating Character Replacement
- 보통Longest Substring With At Least K Repeating Characters
- 보통Longest Substring With At Most K Distinct Characters
- 보통Longest Substring With At Most Two Distinct Characters
- 보통Maximum Number of Vowels in a Substring of Given Length
- 보통Maximum Points You Can Obtain from Cards
- 보통Maximum Sum of Distinct Subarrays With Length K
- 보통Minimum Window Subsequence
- 보통Partition Array Such That Maximum Difference Is K
- 보통Subarray Product Less Than K
- 보통Subarrays with K Different Integers
- 보통Substring With Concatenation of All Words
- 보통Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
- 보통Longest Turbulent Subarray
- 보통Shortest Subarray with Sum at Least K
Kadane's Algorithm6개
Matrix10개
Linked List29개
- 보통Middle of the Linked List
- 보통Remove Nth Node From End of List
- 보통Reverse Linked List
- 보통Reverse Linked List II
- 보통Reverse Nodes in k-Group
- 보통Remove Duplicates from Sorted List II
- 보통Merge Two Sorted Lists
- 보통Linked List Cycle II
- 보통Swap Nodes in Pairs
- 보통Partition List
- 보통Rotate List
- 보통Add Two Numbers
- 보통Copy List with Random Pointer
- 보통Flatten a Multilevel Doubly Linked List
- 보통Intersection of Two Linked Lists
- 보통Add Two Numbers II
- 보통Convert Sorted List to Binary Search Tree
- 보통Delete the Middle Node of a Linked List
- 보통Delete Node in a Linked List
- 보통Design Linked List
- 보통Insert Node in Linked List
- 보통Insert into a Sorted Circular Linked List
- 보통LRU Cache
- 보통Merge In Between Linked Lists
- 보통Odd Even Linked List
- 보통Palindrome Linked List
- 보통Remove Duplicates from Sorted List
- 보통Reorder List
- 보통Sort List
Stack45개
- 보통Valid Parentheses
- 보통Remove All Adjacent Duplicates In String
- 보통Remove Duplicate Letters
- 보통Removing Stars From a String
- 보통Evaluate Reverse Polish Notation
- 보통Basic Calculator II
- 보통Longest Valid Parentheses
- 보통Next Greater Element I
- 보통Daily Temperatures
- 보통132 Pattern
- 보통Number of Visible People in a Queue
- 보통Largest Rectangle in Histogram
- 보통Asteroid Collision
- 보통Baseball Game
- 보통Basic Calculator
- 보통Buildings With an Ocean View
- 보통Car Fleet
- 보통Create Maximum Number
- 보통Decode String
- 보통Design a Text Editor
- 보통Design Browser History
- 보통Exclusive Time of Functions
- 보통Find the Most Competitive Subsequence
- 보통Implement Queue Using Stacks
- 보통Implement Stack Using Queues
- 보통Max Stack
- 보통Maximum Frequency Stack
- 보통Maximum Nesting Depth of the Parentheses
- 보통Maximum Score From Removing Substrings
- 보통Maximum Width Ramp
- 보통Min Stack
- 보통Minimum Add to Make Parentheses Valid
- 보통Minimum Remove to Make Valid Parentheses
- 보통Next Greater Element II
- 보통Next Greater Node In Linked List
- 보통Online Stock Span
- 보통Remove Invalid Parentheses
- 보통Remove K Digits
- 보통Simplify Path
- 보통Valid Parenthesis String
- 보통Validate Stack Sequences
- 보통Final Prices With a Special Discount in a Shop
- 보통Max Chunks To Make Sorted
- 보통Sum of Subarray Minimums
- 보통Sum of Subarray Ranges
Queue12개
QuickSelect1개
Heaps1개
Binary Search27개
- 보통Search Insert Position
- 보통Search in Rotated Sorted Array
- 보통Find Peak Element
- 보통Find Minimum in Rotated Sorted Array
- 보통Search in 2D Matrix
- 보통Binary Search
- 보통Capacity To Ship Packages Within D Days
- 보통Find First and Last Position of Element in Sorted Array
- 보통Find First Occurrence
- 보통Find in Mountain Array
- 보통Find K Closest Elements
- 보통Find K-th Smallest Pair Distance
- 보통Find Smallest Letter Greater Than Target
- 보통First Bad Version
- 보통Guess Number Higher or Lower
- 보통Koko Eating Bananas
- 보통Magnetic Force Between Two Balls
- 보통Minimum Number of Days to Make m Bouquets
- 보통Most Profit Assigning Work
- 보통Search a 2D Matrix II
- 보통Search in Rotated Sorted Array II
- 보통Snapshot Array
- 보통Split Array Largest Sum
- 보통Time Based Key-Value Store
- 보통Valid Perfect Square
- 보통Median of Two Sorted Arrays
- 보통Random Pick with Weight
Backtracking17개
- 어려움Subsets
- 어려움Permutations
- 어려움Combination Sum
- 어려움Combination Sum II
- 어려움Combination Sum III
- 어려움Combinations
- 어려움Generate Parentheses
- 어려움Letter Combinations of a Phone Number
- 어려움N-Queens
- 어려움Palindrome Partitioning
- 어려움Permutations II
- 어려움Restore IP Addresses
- 어려움Subsets II
- 어려움Sudoku Solver
- 어려움Unique Paths III
- 어려움Word Search
- 어려움Word Squares
Tree46개
- 보통Binary Tree Level Order Traversal
- 보통Binary Tree Right Side View
- 보통Binary Tree Zigzag Level Order Traversal
- 보통Populating Next Right Pointers in Each Node II
- 보통Binary Tree Preorder Traversal
- 보통Same Tree
- 보통Symmetric Tree
- 보통Binary Tree Paths
- 보통Convert Sorted Array to Binary Search Tree
- 보통Maximum Difference Between Node and Ancestor
- 보통Path Sum III
- 보통Binary Tree Inorder Traversal
- 보통Minimum Distance Between BST Nodes
- 보통Validate Binary Search Tree
- 보통Kth Smallest Element in a BST
- 보통Binary Tree Postorder Traversal
- 보통Invert Binary Tree
- 보통Diameter of Binary Tree
- 보통Lowest Common Ancestor of a Binary Tree
- 보통Find Duplicate Subtrees
- 보통Flatten Binary Tree to Linked List
- 보통Distribute Coins in Binary Tree
- 보통House Robber III
- 보통Binary Tree Maximum Path Sum
- 보통Binary Tree Cameras
- 보통Average of Levels in Binary Tree
- 보통Balanced Binary Tree
- 보통Boundary of Binary Tree
- 보통Check Completeness of a Binary Tree
- 보통Construct Binary Tree from Inorder and Postorder Traversal
- 보통Construct Binary Tree from Preorder and Inorder Traversal
- 보통Construct Quad Tree
- 보통Count Complete Tree Nodes
- 보통Count Good Nodes in Binary Tree
- 보통Delete Nodes And Return Forest
- 보통Longest Univalue Path
- 보통Maximum Binary Tree
- 보통Maximum Width of Binary Tree
- 보통Path Sum II
- 보통Populating Next Right Pointers in Each Node
- 보통Serialize and Deserialize Binary Tree
- 보통Step-By-Step Directions From a Binary Tree Node to Another
- 보통Subtree of Another Tree
- 보통Sum of Left Leaves
- 보통Sum Root to Leaf Numbers
- 보통Vertical Order Traversal of a Binary Tree
BST18개
- 보통Trim Binary Search Tree
- 보통Balance a Binary Search Tree
- 보통Binary Search Tree Iterator
- 보통Closest Binary Search Tree Value
- 보통Construct BST from Preorder Traversal
- 보통Convert BST to Sorted Doubly Linked List
- 보통Delete from BST
- 보통Delete Node in a BST
- 보통Inorder Successor in BST
- 보통Inorder Successor in BST II
- 보통Insert into BST
- 보통Insert into a Binary Search Tree
- 보통Largest BST Subtree
- 보통Lowest Common Ancestor of a BST
- 보통Minimum Absolute Difference in BST
- 보통Range Sum of BST
- 보통Recover Binary Search Tree
- 보통Search in a Binary Search Tree
Tries12개
- 어려움Search Suggestions System
- 어려움Word Search II
- 어려움Design Add and Search Words Data Structure
- 어려움Design In-Memory File System
- 어려움Design Search Autocomplete System
- 어려움Implement Trie
- 어려움Implement Trie (Prefix Tree)
- 어려움Longest Word in Dictionary
- 어려움Maximum XOR of Two Numbers in an Array
- 어려움Replace Words
- 어려움Stream of Characters
- 어려움Remove Sub-Folders from the Filesystem
Heap27개
- 보통Sort Characters By Frequency
- 보통Furthest Building You Can Reach
- 보통Top K Frequent Elements
- 보통Find Median from Data Stream
- 보통IPO
- 보통K Closest Points to Origin
- 보통Find K Pairs with Smallest Sums
- 보통Merge k Sorted Lists
- 보통All O'one Data Structure
- 보통Employee Free Time
- 보통Kth Largest Element in a Stream
- 보통Find the Kth Largest Integer in the Array
- 보통Last Stone Weight
- 보통LFU Cache
- 보통Maximum Performance of a Team
- 보통Minimum Cost to Connect Sticks
- 보통Minimum Cost to Hire K Workers
- 보통Minimum Number of Refueling Stops
- 보통Process Tasks Using Servers
- 보통Single-Threaded CPU
- 보통The Skyline Problem
- 보통Sliding Window Median
- 보통Smallest Range Covering Elements from K Lists
- 보통Stock Price Fluctuation
- 보통Task Scheduler
- 보통Top K Frequent Words
- 보통Two Best Non-Overlapping Events
Intervals19개
- 보통Merge Intervals
- 보통Insert Interval
- 보통Minimum Number of Arrows to Burst Balloons
- 보통Non-overlapping Intervals
- 보통Kth Smallest Element in Sorted Matrix
- 보통Maximum Number of Events That Can Be Attended
- 보통Avoid Flood in The City
- 보통Car Pooling
- 보통Heaters
- 보통Interval List Intersections
- 보통Meeting Rooms
- 보통Meeting Rooms II
- 보통Meeting Rooms III
- 보통Meeting Scheduler
- 보통Minimum Interval to Include Each Query
- 보통My Calendar I
- 보통My Calendar II
- 보통Remove Covered Intervals
- 보통Set Intersection Size At Least Two
Greedy13개
Graph80개
- 어려움Depth First Search
- 어려움Number of Islands
- 어려움Time Needed to Inform All Employees
- 어려움Employee Importance
- 어려움Clone Graph
- 어려움Is Graph Bipartite?
- 어려움All Nodes Distance K in Binary Tree
- 어려움Rotting Oranges
- 어려움Word Ladder
- 어려움Course Schedule II
- 어려움Find Eventual Safe States
- 어려움Minimum Height Trees
- 어려움Number of Provinces
- 어려움Redundant Connection
- 어려움Minimize Malware Spread
- 어려움Course Schedule IV
- 어려움Parallel Courses
- 어려움Flood Fill
- 어려움Number of Distinct Islands
- 어려움Find All Possible Recipes
- 어려움Sort Items by Groups
- 어려움Alien Dictionary
- 어려움Connected Components
- 어려움Surrounded Regions
- 어려움Graph Valid Tree
- 어려움Accounts Merge
- 어려움Evaluate Division
- 어려움Most Stones Removed
- 어려움Number of Islands II
- 어려움Critical Connections in a Network
- 어려움Longest Path With Different Adjacent Characters
- 어려움01 Matrix
- 어려움Walls and Gates
- 어려움Open the Lock
- 어려움Snakes and Ladders
- 어려움Minimum Genetic Mutation
- 어려움Minimum Knight Moves
- 어려움Shortest Path in Binary Matrix
- 어려움Path With Maximum Minimum Value
- 어려움Shortest Path with Obstacles Elimination
- 어려움Bus Routes
- 어려움Minimum Obstacle Removal to Reach Corner
- 어려움Cheapest Flights Within K Stops
- 어려움Path with Maximum Probability
- 어려움Path With Minimum Effort
- 어려움The Maze II
- 어려움Minimum Cost to Convert String I
- 어려움Find Minimum Time to Reach Last Room I
- 어려움Swim in Rising Water
- 어려움Minimum Cost to Make at Least One Valid Path in a Grid
- 어려움Minimum Weighted Subgraph With the Required Paths
- 어려움Min Cost to Connect All Points
- 어려움Connecting Cities With Minimum Cost
- 어려움Optimize Water Distribution in a Village
- 어려움Cracking the Safe
- 어려움Valid Arrangement of Pairs
- 어려움A* Search Algorithm
- 어려움All Paths From Source to Target
- 어려움Bellman-Ford Algorithm
- 어려움Breadth First Search
- 어려움Centroid Decomposition
- 어려움Find Critical and Pseudo-Critical Edges in MST
- 어려움Detect Cycle in Directed Graph
- 어려움Detect Cycle in Undirected Graph
- 어려움Dijkstra's Algorithm
- 어려움Floyd-Warshall Algorithm
- 어려움Heavy-Light Decomposition
- 어려움Kosaraju's SCC Algorithm
- 어려움Kruskal's MST Algorithm
- 어려움Making A Large Island
- 어려움Maximize Spanning Tree Stability
- 어려움Network Delay Time
- 어려움Number of Connected Components in an Undirected Graph
- 어려움Number of Enclaves
- 어려움Pacific Atlantic Water Flow
- 어려움Prim's MST Algorithm
- 어려움Reconstruct Itinerary
- 어려움Tarjan's Algorithm
- 어려움Topological Sort
- 어려움Union-Find (Disjoint Set Union)
Dynamic Programming84개
- 어려움Longest Increasing Subsequence
- 어려움Minimum Path Sum
- 어려움Russian Doll Envelopes
- 어려움Climbing Stairs
- 어려움Min Cost Climbing Stairs
- 어려움House Robber
- 어려움House Robber II
- 어려움Unique Paths II
- 어려움Count Square Submatrices with All Ones
- 어려움Maximum Number of Points with Cost
- 어려움Burst Balloons
- 어려움Maximum Profit in Job Scheduling
- 어려움Longest Common Subsequence
- 어려움Edit Distance
- 어려움Longest Palindromic Subsequence
- 어려움Decode Ways
- 어려움Wildcard Matching
- 어려움Distinct Subsequences
- 어려움Coin Change
- 어려움Coin Change II
- 어려움Perfect Squares
- 어려움Partition Equal Subset Sum
- 어려움Target Sum
- 어려움Last Stone Weight II
- 어려움Triangle
- 어려움Fibonacci Number
- 어려움Maximum Length of Pair Chain
- 어려움Delete and Earn
- 어려움Integer Break
- 어려움Greatest Sum Divisible by Three
- 어려움Number of Ways to Paint N × 3 Grid
- 어려움Ones and Zeroes
- 어려움Profitable Schemes
- 어려움Minimum Cost For Tickets
- 어려움Number of Longest Increasing Subsequence
- 어려움Longest String Chain
- 어려움Longest Arithmetic Subsequence
- 어려움Pascal's Triangle
- 어려움Unique Paths
- 어려움Maximal Square
- 어려움Paint House
- 어려움Minimum Falling Path Sum
- 어려움Remove Boxes
- 어려움Maximal Rectangle
- 어려움Cherry Pickup
- 어려움Dungeon Game
- 어려움Longest Increasing Path in a Matrix
- 어려움Painting a Grid With Three Different Colors
- 어려움Minimum Cost Path with Teleportations
- 어려움Frog Jump
- 어려움Optimal Account Balancing
- 어려움Minimum Difficulty of a Job Schedule
- 어려움Minimum Cost to Cut a Stick
- 어려움Word Break
- 어려움Interleaving String
- 어려움Minimum Deletions to Make String Balanced
- 어려움Word Break II
- 어려움Regular Expression Matching
- 어려움Palindrome Partitioning II
- 어려움Strange Printer
- 어려움Shortest Common Supersequence
- 어려움Unique Binary Search Trees II
- 어려움Number of Ways to Arrive at Destination
- 어려움Sum of Distances in Tree
- 어려움Campus Bikes II
- 어려움Partition to K Equal Sum Subsets
- 어려움Minimum Number of Work Sessions
- 어려움Fair Distribution of Cookies
- 어려움Shortest Path Visiting All Nodes
- 어려움Count Numbers with Unique Digits
- 어려움Number of Digit One
- 어려움Numbers At Most N Given Digit Set
- 어려움Knight Probability in Chessboard
- 어려움Soup Servings
- 어려움New 21 Game
- 어려움Best Time to Buy and Sell Stock with Cooldown
- 어려움Best Time to Buy and Sell Stock with Transaction Fee
- 어려움Best Time to Buy and Sell Stock III
- 어려움Best Time to Buy and Sell Stock IV
- 어려움Longest Palindromic Substring
- 어려움Concatenated Words
- 어려움Constrained Subsequence Sum
- 어려움Count of Range Sum
- 어려움Number of People Aware of a Secret
BIT / Segment Tree16개
- 어려움Range Sum Query - Mutable
- 어려움Range Sum Query 2D - Mutable
- 어려움Count of Smaller Numbers After Self
- 어려움Falling Squares
- 어려움Block Placement Queries
- 어려움Longest Balanced Subarray II
- 어려움Number of Pairs Satisfying Inequality
- 어려움Fenwick Tree (Binary Indexed Tree)
- 어려움Range Module
- 어려움Range Sum Query 2D - Immutable
- 어려움Range Sum Query - Immutable
- 어려움Reverse Pairs
- 어려움Segment Tree
- 어려움Segment Tree with Lazy Propagation
- 어려움Sparse Table
- 어려움Sqrt Decomposition