Tree Breadth-First Search (BFS)
Trees & GraphsLevel-order traversal and horizontal tier exploration using queues
382 problems·42 Easy·238 Medium·102 Hard
Pattern Study Guide & Cheat Sheet▼
Traverse tree level by level using a FIFO queue, processing all nodes at depth D before any node at depth D+1.
Core Invariant: Level Snapshot: At the start of each while loop iteration, `len(queue)` EXACTLY equals the number of nodes on the current level. Process that fixed count in a loop before touching the next level.
Recognize it (Keywords & Signals)
- Level order traversal / zigzag level order
- Binary tree right side view
- Populate next right pointers in each node
- Minimum depth of binary tree (earliest leaf found)
When NOT to use
Path sum from root to leaf or deep ancestor queries (Tree DFS is simpler and uses less auxiliary memory).
How to solve (Step-by-step)
- 1.If `not root: return []`.
- 2.Initialize `queue = collections.deque([root])`.
- 3.While `queue`: capture `level_size = len(queue)` and create `current_level = []`.
- 4.Loop `for _ in range(level_size)`: pop `node = queue.popleft()`, append `node.val` to `current_level`.
- 5.Enqueue children: `if node.left: queue.append(node.left)` and `if node.right: queue.append(node.right)`.
- 6.Append `current_level` to `result`.
Watch for (Interview Traps)
- Using dynamic `len(queue)` directly in `while` loop condition without freezing `level_size`
- Forgetting to check `if not root:` before creating queue (adds `None` to queue)
- Using a Python list as queue with `pop(0)` (which is O(N) per pop!) instead of `deque.popleft()` (O(1))
Level-by-Level Tree BFS (Level Order Traversal)
from collections import deque
def level_order(root: TreeNode | None) -> list[list[int]]:
if not root:
return []
levels = []
queue = deque([root])
while queue:
level_size = len(queue) # Snapshot number of nodes at this depth
curr_level = []
for _ in range(level_size):
node = queue.popleft()
curr_level.append(node.val)
if node.left:
queue.append(node.left)
if node.right:
queue.append(node.right)
levels.append(curr_level)
return levels- Cost
- O(N) visits each node once · O(W) where W is maximum width of tree (up to N/2 at bottom level) (Optimal for level-oriented questions.)
Canonical problems
#102 Binary Tree Level Order Traversal: Standard level batching
#199 Binary Tree Right Side View: Last element in each level snapshot is visible from the right
#103 Binary Tree Zigzag Level Order Traversal: Reverse alternate level arrays or use deque
#111 Minimum Depth of Binary Tree: First leaf node encountered across levels guarantees minimum depth
⌘K
Medium·25 companies·Max freq 100%·Acc 64.4%
Tower Research CapitalTower Research CapitalUrban Company+22
Hard·25 companies·Max freq 100%·Acc 61.1%
YahooHiveNeetCode 150+22
Medium·24 companies·Max freq 100%·Acc 69.7%
NewsBreakAirwallexMeta+21
Medium·23 companies·Max freq 88%·Acc 36.0%
WixNeetCode 150NeetCode 150+20
Medium·22 companies·Max freq 100%·Acc 42.2%
HTCMakeMyTripStripe+19
Easy·20 companies·Max freq 100%·Acc 78.4%
YahooNeetCode 150NeetCode 150+17
Hard·20 companies·Max freq 93%·Acc 56.8%
DoorDashWeRideDuolingo+17
Medium·19 companies·Max freq 100%·Acc 64.1%
SigmoidNutanixAdobe+16
Medium·18 companies·Max freq 100%·Acc 73.0%
GojekNeetCode 150NeetCode 150+15
#934Shortest Bridge
Medium·18 companies·Max freq 100%·Acc 59.6%
Tower Research CapitalMcKinseyTower Research Capital+15
Hard·16 companies·Max freq 100%·Acc 0.5%
AppFolioPinterestIMC+13
Hard·15 companies·Max freq 100%·Acc 45.0%
ZenefitsGleanApplied Intuition+12
Hard·15 companies·Max freq 100%·Acc 54.2%
SamsungRokuMeta+12
Medium·14 companies·Max freq 100%·Acc 61.2%
Urban CompanyServiceNowNeetCode 150+11
Medium·14 companies·Max freq 88%·Acc 77.0%
UberNeetCode 150NeetCode 150+11
Medium·13 companies·Max freq 100%·Acc 65.7%
blinkitShareChatServiceNow+10
Medium·12 companies·Max freq 83%·Acc 69.1%
NeetCode 150NeetCode 150TikTok+9
Medium·11 companies·Max freq 100%·Acc 66.9%
Akuna CapitalPhonePeIBM+8
Medium·11 companies·Max freq 89%·Acc 83.0%
MetaLinkedInMongoDB+8
Easy·11 companies·Max freq 87%·Acc 80.2%
NeetCode 150NeetCode 150Josh Technology+8
Hard·11 companies·Max freq 77%·Acc 60.0%
UberMathWorksMeesho+8
Medium·10 companies·Max freq 100%·Acc 66.9%
ZenefitsLyftSalesforce+7
Medium·10 companies·Max freq 100%·Acc 65.1%
XGeneral MotorsX+7
#113Path Sum II
Medium·10 companies·Max freq 63%·Acc 62.5%
Arista NetworksPalo Alto NetworksFlipkart+7
Medium·9 companies·Max freq 84%·Acc 73.9%
NeetCode 150NeetCode 150Josh Technology+6
Easy·9 companies·Max freq 75%·Acc 75.8%
AirbnbAccentureAmazon+6
Medium·9 companies·Max freq 53%·Acc 48.8%
eBayUberWalmart Labs+6
Medium·8 companies·Max freq 64%·Acc 77.3%
Zeta GlobalGoldman Sachstcs+5
Medium·8 companies·Max freq 53%·Acc 67.4%
Walmart LabsBloombergMeta+5
Medium·8 companies·Max freq 52%·Acc 66.3%
Josh TechnologyLinkedInApple+5
Medium·7 companies·Max freq 100%·Acc 83.9%
ClariLinkedInUber+4
Medium·7 companies·Max freq 88%·Acc 72.4%
GopuffJosh TechnologyMicrosoft+4
Hard·7 companies·Max freq 63%·Acc 0.6%
CitadelSquarepoint CapitalPalo Alto Networks+4
Medium·7 companies·Max freq 63%·Acc 73.5%
AndurilMicrosoftAmazon+4
Medium·7 companies·Max freq 63%·Acc 69.1%
Walmart LabsMicrosoftTikTok+4
Medium·7 companies·Max freq 50%·Acc 57.8%
BloombergMetaMicrosoft+4
Medium·6 companies·Max freq 100%·Acc 51.2%
Pocket GemsDocusignMicrosoft+3
Hard·6 companies·Max freq 100%·Acc 0.5%
Hudson River TradingHudson River TradingTarget+3
Hard·6 companies·Max freq 100%·Acc 0.5%
thoughtspotWeRideUber+3
Medium·6 companies·Max freq 88%·Acc 56.5%
DatabricksSnowflakeTikTok+3
Hard·6 companies·Max freq 70%·Acc 83.3%
GrammarlyAmazonGoogle+3
Hard·6 companies·Max freq 63%·Acc 66.9%
UberAccentureGoogle+3
Medium·6 companies·Max freq 38%·Acc 84.4%
AmazonSalesforceMeta+3
Medium·6 companies·Max freq 25%·Acc 68.6%
OracleBloombergAmazon+3
Medium·6 companies·Max freq 25%·Acc 78.1%
AppleGoogleBloomberg+3
Medium·5 companies·Max freq 100%·Acc 51.8%
ZenefitsExpediaSalesforce+2
Medium·5 companies·Max freq 77%·Acc 59.3%
FlipkartTekionAmazon+2
Medium·5 companies·Max freq 63%·Acc 78.2%
Josh TechnologyEPAM SystemsAmazon+2
Medium·5 companies·Max freq 63%·Acc 63.8%
CiscoPhonePeMeta+2
Medium·5 companies·Max freq 63%·Acc 83.7%
BloombergNetflixAmazon+2
Medium·5 companies·Max freq 63%·Acc 0.5%
SnapSnapAmazon+2
Hard·5 companies·Max freq 56%·Acc 66.0%
CitadelMetaAmazon+2
Medium·5 companies·Max freq 50%·Acc 66.0%
TikTokMicrosoftAmazon+2
Medium·5 companies·Max freq 38%·Acc 55.8%
MicrosoftAmazonGoogle+2
Medium·5 companies·Max freq 38%·Acc 65.4%
MicrosoftAmazonUber+2
Hard·4 companies·Max freq 100%·Acc 69.4%
Deutsche BankBlackRockMeta+1
Hard·4 companies·Max freq 100%·Acc 57.0%
ServiceNowOracleMicrosoft+1
Medium·4 companies·Max freq 89%·Acc 53.5%
GuidewireBoltAmazon+1
Hard·4 companies·Max freq 88%·Acc 67.2%
AirbnbLyftBloomberg+1
Medium·4 companies·Max freq 67%·Acc 77.2%
Josh TechnologyAmazonMicrosoft+1
Medium·4 companies·Max freq 64%·Acc 65.6%
MetaTikTokAmazon+1
Medium·4 companies·Max freq 63%·Acc 86.0%
Josh TechnologySalesforceAmazon+1
Medium·4 companies·Max freq 63%·Acc 62.3%
OracleGoogleAmazon+1
Medium·4 companies·Max freq 63%·Acc 79.6%
AtlassianAmazonTikTok+1
Hard·4 companies·Max freq 63%·Acc 56.1%
AtlassianMicrosoftGoogle+1
Medium·4 companies·Max freq 53%·Acc 86.8%
MetaSnowflakeAmazon+1
Medium·4 companies·Max freq 51%·Acc 69.7%
LinkedInMetaAtlassian+1
Medium·4 companies·Max freq 50%·Acc 54.8%
TikTokGoogleMeta+1
Medium·4 companies·Max freq 39%·Acc 77.6%
MetaBloombergAmazon+1
Medium·4 companies·Max freq 38%·Acc 79.5%
MetaGoogleBloomberg+1
Hard·4 companies·Max freq 38%·Acc 45.1%
InfosysAmazonMicrosoft+1
Hard·4 companies·Max freq 38%·Acc 74.0%
InfosysGoogleAmazon+1
Medium·4 companies·Max freq 28%·Acc 70.0%
GoogleMetaMicrosoft+1
Medium·4 companies·Max freq 28%·Acc 44.6%
UberMetaAmazon+1
Hard·4 companies·Max freq 25%·Acc 76.1%
AmazonMetaMicrosoft+1
Medium·4 companies·Max freq 16%·Acc 80.8%
MicrosoftMetaAmazon+1
Hard·3 companies·Max freq 100%·Acc 0.3%
GameskraftUberLinkedIn
Hard·3 companies·Max freq 100%·Acc 24.0%
HuaweiWorldQuantDE Shaw
Medium·3 companies·Max freq 100%·Acc 64.5%
RobinhoodSamsungGoogle
Medium·3 companies·Max freq 100%·Acc 55.8%
Deutsche BankAtlassianAmazon
Medium·3 companies·Max freq 100%·Acc 56.2%
UBSthoughtspotRippling
Medium·3 companies·Max freq 100%·Acc 74.3%
GuidewireAmazonGoogle
Medium·3 companies·Max freq 60%·Acc 61.7%
RipplingUberGoogle
Hard·3 companies·Max freq 38%·Acc 54.9%
SnowflakeGoogleMeta
Medium·3 companies·Max freq 25%·Acc 50.1%
UberGoogleMeta
Medium·3 companies·Max freq 16%·Acc 61.9%
MicrosoftAmazonGoogle
Hard·3 companies·Max freq 13%·Acc 72.5%
BloombergAmazonGoogle
Medium·2 companies·Max freq 100%·Acc 48.9%
GrowwMicrosoft
Medium·2 companies·Max freq 100%·Acc 69.4%
JioGoogle
Hard·2 companies·Max freq 100%·Acc 73.1%
JioGoogle
Medium·2 companies·Max freq 88%·Acc 0.5%
Booking.comBooking.com
Medium·2 companies·Max freq 88%·Acc 55.5%
SamsungUber
Medium·2 companies·Max freq 79%·Acc 56.2%
IntuitGoogle
Medium·2 companies·Max freq 25%·Acc 84.1%
GoogleAmazon
Medium·2 companies·Max freq 16%·Acc 41.4%
GoogleMicrosoft
Hard·2 companies·Max freq 13%·Acc 56.5%
MetaGoogle
Hard·1 companies·Max freq 90%·Acc 47.0%
Sprinklr
Hard·1 companies·Max freq 75%·Acc 36.9%
DE Shaw
Hard·1 companies·Max freq 75%·Acc 72.9%
Airbnb
Medium·1 companies·Max freq 63%·Acc 58.1%
Oracle
Medium·1 companies·Max freq 28%·Acc 82.5%
Amazon
Easy·1 companies·Max freq 27%·Acc 85.9%
Meta
Hard·1 companies·Max freq 25%·Acc 62.9%
Amazon
Medium·1 companies·Max freq 25%·Acc 28.0%
Google
Medium·1 companies·Max freq 25%·Acc 47.5%
Google
Hard·1 companies·Max freq 13%·Acc 49.9%
Google
Medium·1 companies·Max freq 13%·Acc 62.4%
Google
# | Problem | Difficulty | Top Companies↓ | Frequency | Acceptance | |
|---|---|---|---|---|---|---|
| #200 | Number of Islands ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 100% | 64.7% | ||
| #994 | Rotting Oranges ArrayBreadth-First SearchMatrix | Medium | 100% | 59.0% | ||
| #207 | Course Schedule Depth-First SearchBreadth-First SearchGraph TheoryTopological SortDirected Acyclic Graph | Medium | 100% | 51.8% | ||
| #127 | Word Ladder Hash TableStringBreadth-First SearchBidirectional Search | Hard | 100% | 46.0% | ||
| #322 | Coin Change ArrayDynamic ProgrammingBreadth-First SearchKnapsack ProblemComplete Knapsack | Medium | 100% | 48.7% | ||
| #210 | Course Schedule II Depth-First SearchBreadth-First SearchGraph TheoryTopological Sort | Medium | 100% | 55.9% | ||
| #124 | Binary Tree Maximum Path Sum Dynamic ProgrammingTreeDepth-First SearchBinary TreeDP on Trees | Hard | 100% | 42.5% | ||
| #399 | Evaluate Division ArrayStringDepth-First SearchBreadth-First SearchUnion-FindGraph TheoryShortest PathBellman–Ford AlgorithmFloyd–Warshall Algorithm | Medium | 100% | 64.4% | ||
| #297 | Serialize and Deserialize Binary Tree StringTreeDepth-First SearchBreadth-First SearchDesignBinary Tree | Hard | 100% | 61.1% | ||
| #236 | Lowest Common Ancestor of a Binary Tree TreeDepth-First SearchBinary TreeBinary LiftingLowest Common Ancestor | Medium | 100% | 69.7% | ||
| #269 | Alien Dictionary ArrayStringDepth-First SearchBreadth-First SearchGraph TheoryTopological SortDirected Acyclic Graph | Hard | 100% | 37.3% | ||
| #543 | Diameter of Binary Tree TreeDepth-First SearchBinary TreeDP on Trees | Easy | 88% | 65.8% | ||
| #98 | Validate Binary Search Tree TreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 88% | 36.0% | ||
| #787 | Cheapest Flights Within K Stops Dynamic ProgrammingDepth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)Shortest Path | Medium | 100% | 42.2% | ||
| #695 | Max Area of Island ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 100% | 74.1% | ||
| #341 | Flatten Nested List Iterator StackTreeDepth-First SearchDesignQueueIterator | Medium | 100% | 65.8% | ||
| #104 | Maximum Depth of Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 100% | 78.4% | ||
| #133 | Clone Graph Hash TableDepth-First SearchBreadth-First SearchGraph Theory | Medium | 100% | 65.7% | ||
| #329 | Longest Increasing Path in a Matrix ArrayDynamic ProgrammingDepth-First SearchBreadth-First SearchGraph TheoryTopological SortMemoizationMatrixDirected Acyclic Graph | Hard | 93% | 56.8% | ||
| #863 | All Nodes Distance K in Binary Tree Hash TableTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 89% | 67.8% | ||
| #103 | Binary Tree Zigzag Level Order Traversal TreeBreadth-First SearchBinary Tree | Medium | 100% | 64.1% | ||
| #815 | Bus Routes ArrayHash TableBreadth-First Search | Hard | 100% | 47.4% | ||
| #102 | Binary Tree Level Order Traversal TreeBreadth-First SearchBinary Tree | Medium | 100% | 73.0% | ||
| #934 | Shortest Bridge ArrayDepth-First SearchBreadth-First SearchMatrix | Medium | 100% | 59.6% | ||
| #752 | Open the Lock ArrayHash TableStringBreadth-First SearchBidirectional Search | Medium | 100% | 0.6% | ||
| #968 | Binary Tree Cameras Dynamic ProgrammingTreeDepth-First SearchBinary TreeDP on Trees | Hard | 100% | 48.0% | ||
| #199 | Binary Tree Right Side View TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 88% | 70.7% | ||
| #721 | Accounts Merge ArrayHash TableStringDepth-First SearchBreadth-First SearchUnion-FindSorting | Medium | 83% | 61.6% | ||
| #126 | Word Ladder II Hash TableStringBacktrackingBreadth-First SearchBidirectional Search | Hard | 100% | 27.8% | ||
| #1293 | Shortest Path in a Grid with Obstacles Elimination ArrayBreadth-First SearchMatrix | Hard | 100% | 0.5% | ||
| #317 | Shortest Distance from All Buildings ArrayBreadth-First SearchMatrix | Hard | 100% | 45.0% | ||
| #987 | Vertical Order Traversal of a Binary Tree Hash TableTreeDepth-First SearchBreadth-First SearchSortingBinary Tree | Hard | 100% | 54.2% | ||
| #130 | Surrounded Regions ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 87% | 0.5% | ||
| #1091 | Shortest Path in Binary Matrix ArrayBreadth-First SearchMatrix | Medium | 81% | 51.8% | ||
| #417 | Pacific Atlantic Water Flow ArrayDepth-First SearchBreadth-First SearchMatrix | Medium | 100% | 61.2% | ||
| #542 | 01 Matrix ArrayDynamic ProgrammingBreadth-First SearchMatrix | Medium | 100% | 54.4% | ||
| #230 | Kth Smallest Element in a BST TreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 88% | 77.0% | ||
| #490 | The Maze ArrayDepth-First SearchBreadth-First SearchMatrix | Medium | 63% | 60.5% | ||
| #279 | Perfect Squares MathDynamic ProgrammingBreadth-First SearchKnapsack ProblemComplete Knapsack | Medium | 100% | 56.7% | ||
| #286 | Walls and Gates ArrayBreadth-First SearchMatrix | Medium | 100% | 64.1% | ||
| #2603 | Collect Coins in a Tree ArrayTreeGraph TheoryTopological Sort | Hard | 100% | 39.5% | ||
| #2385 | Amount of Time for Binary Tree to Be Infected Hash TableTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 100% | 65.7% | ||
| #694 | Number of Distinct Islands ArrayHash TableDepth-First SearchBreadth-First SearchUnion-FindSortingMatrixHash Function | Medium | 92% | 62.9% | ||
| #337 | House Robber III Dynamic ProgrammingTreeDepth-First SearchBinary TreeDP on Trees | Medium | 88% | 56.1% | ||
| #733 | Flood Fill ArrayDepth-First SearchBreadth-First SearchMatrix | Easy | 88% | 68.6% | ||
| #1197 | Minimum Knight Moves Breadth-First SearchHeuristic SearchBidirectional SearchA* Search | Medium | 88% | 42.0% | ||
| #105 | Construct Binary Tree from Preorder and Inorder Traversal ArrayHash TableDivide and ConquerTreeBinary Tree | Medium | 83% | 69.1% | ||
| #886 | Possible Bipartition Depth-First SearchBreadth-First SearchUnion-FindGraph TheoryGraph ColoringBipartite Graph | Medium | 75% | 52.8% | ||
| #101 | Symmetric Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 66% | 61.6% | ||
| #909 | Snakes and Ladders ArrayBreadth-First SearchMatrix | Medium | 63% | 48.2% | ||
| #110 | Balanced Binary Tree TreeDepth-First SearchBinary Tree | Easy | 100% | 58.7% | ||
| #261 | Graph Valid Tree Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 100% | 50.1% | ||
| #1319 | Number of Operations to Make Network Connected Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 100% | 66.9% | ||
| #743 | Network Delay Time Depth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)Shortest PathDijkstra's Algorithm | Medium | 100% | 61.0% | ||
| #314 | Binary Tree Vertical Order Traversal Hash TableTreeDepth-First SearchBreadth-First SearchSortingBinary Tree | Medium | 93% | 57.9% | ||
| #572 | Subtree of Another Tree TreeDepth-First SearchString MatchingBinary TreeHash Function | Easy | 89% | 51.9% | ||
| #1650 | Lowest Common Ancestor of a Binary Tree III Hash TableTwo PointersTreeBinary TreeBinary LiftingLowest Common Ancestor | Medium | 89% | 83.0% | ||
| #785 | Is Graph Bipartite? Depth-First SearchBreadth-First SearchUnion-FindGraph TheoryGraph ColoringBipartite Graph | Medium | 88% | 59.6% | ||
| #96 | Unique Binary Search Trees MathDynamic ProgrammingTreeBinary Search TreeBinary Tree | Medium | 88% | 63.9% | ||
| #226 | Invert Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 87% | 80.2% | ||
| #100 | Same Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 85% | 67.5% | ||
| #778 | Swim in Rising Water ArrayBinary SearchDepth-First SearchBreadth-First SearchUnion-FindMinimaxHeap (Priority Queue)MatrixDijkstra's Algorithm | Hard | 78% | 68.0% | ||
| #2858 | Minimum Edge Reversals So Every Node Is Reachable Dynamic ProgrammingDepth-First SearchBreadth-First SearchGraph Theory | Hard | 77% | 60.0% | ||
| #437 | Path Sum III TreeDepth-First SearchBinary Tree | Medium | 76% | 46.5% | ||
| #684 | Redundant Connection Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 75% | 0.7% | ||
| #450 | Delete Node in a BST TreeBinary Search TreeBinary Tree | Medium | 53% | 55.0% | ||
| #841 | Keys and Rooms Depth-First SearchBreadth-First SearchGraph Theory | Medium | 100% | 76.0% | ||
| #109 | Convert Sorted List to Binary Search Tree Linked ListDivide and ConquerTreeBinary Search TreeBinary Tree | Medium | 100% | 66.9% | ||
| #323 | Number of Connected Components in an Undirected Graph Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 100% | 65.1% | ||
| #924 | Minimize Malware Spread ArrayHash TableDepth-First SearchBreadth-First SearchUnion-FindGraph Theory | Hard | 100% | 43.3% | ||
| #1202 | Smallest String With Swaps ArrayHash TableStringDepth-First SearchBreadth-First SearchUnion-FindSorting | Medium | 100% | 60.8% | ||
| #301 | Remove Invalid Parentheses StringBacktrackingBreadth-First Search | Hard | 76% | 50.0% | ||
| #113 | Path Sum II BacktrackingTreeDepth-First SearchBinary Tree | Medium | 63% | 62.5% | ||
| #545 | Boundary of Binary Tree TreeDepth-First SearchBinary Tree | Medium | 63% | 48.2% | ||
| #1242 | Web Crawler Multithreaded Depth-First SearchBreadth-First SearchConcurrency | Medium | 100% | 51.3% | ||
| #547 | Number of Provinces Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 100% | 70.7% | ||
| #1448 | Count Good Nodes in Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 84% | 73.9% | ||
| #529 | Minesweeper ArrayDepth-First SearchBreadth-First SearchMatrix | Medium | 78% | 68.8% | ||
| #108 | Convert Sorted Array to Binary Search Tree ArrayDivide and ConquerTreeBinary Search TreeBinary Tree | Easy | 75% | 75.8% | ||
| #1631 | Path With Minimum Effort ArrayBinary SearchDepth-First SearchBreadth-First SearchUnion-FindHeap (Priority Queue)MatrixDijkstra's Algorithm | Medium | 67% | 63.6% | ||
| #463 | Island Perimeter ArrayDepth-First SearchBreadth-First SearchMatrix | Easy | 63% | 74.5% | ||
| #652 | Find Duplicate Subtrees Hash TableTreeDepth-First SearchBinary Tree | Medium | 63% | 60.8% | ||
| #1926 | Nearest Exit from Entrance in Maze ArrayBreadth-First SearchMatrix | Medium | 53% | 48.8% | ||
| #112 | Path Sum TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 51% | 55.3% | ||
| #257 | Binary Tree Paths StringBacktrackingTreeDepth-First SearchBinary Tree | Easy | 89% | 69.0% | ||
| #270 | Closest Binary Search Tree Value Binary SearchTreeDepth-First SearchBinary Search TreeBinary Tree | Easy | 88% | 49.2% | ||
| #653 | Two Sum IV - Input is a BST Hash TableTwo PointersTreeDepth-First SearchBreadth-First SearchBinary Search TreeBinary Tree | Easy | 88% | 63.5% | ||
| #427 | Construct Quad Tree ArrayDivide and ConquerTreeMatrix | Medium | 88% | 78.5% | ||
| #979 | Distribute Coins in Binary Tree TreeDepth-First SearchBinary TreeDP on Trees | Medium | 64% | 77.3% | ||
| #173 | Binary Search Tree Iterator StackTreeDesignBinary Search TreeBinary TreeIterator | Medium | 63% | 76.7% | ||
| #617 | Merge Two Binary Trees TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 63% | 79.1% | ||
| #662 | Maximum Width of Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 63% | 45.8% | ||
| #2812 | Find the Safest Path in a Grid ArrayBinary SearchBreadth-First SearchUnion-FindHeap (Priority Queue)Matrix | Medium | 62% | 57.2% | ||
| #116 | Populating Next Right Pointers in Each Node Linked ListTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 53% | 67.4% | ||
| #515 | Find Largest Value in Each Tree Row TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 52% | 66.3% | ||
| #365 | Water and Jug Problem MathDepth-First SearchBreadth-First SearchBézout's LemmaEuclidean AlgorithmGreatest Common DivisorExtended Euclidean Algorithm | Medium | 51% | 45.9% | ||
| #1162 | As Far from Land as Possible ArrayDynamic ProgrammingBreadth-First SearchMatrix | Medium | 100% | 52.4% | ||
| #2196 | Create Binary Tree From Descriptions ArrayHash TableTreeBinary Tree | Medium | 100% | 83.9% | ||
| #310 | Minimum Height Trees Depth-First SearchBreadth-First SearchGraph TheoryTopological Sort | Medium | 100% | 42.6% | ||
| #111 | Minimum Depth of Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 100% | 53.3% | ||
| #1236 | Web Crawler StringDepth-First SearchBreadth-First SearchInteractive | Medium | 100% | 68.8% | ||
| #433 | Minimum Genetic Mutation Hash TableStringBreadth-First SearchBidirectional Search | Medium | 100% | 56.9% | ||
| #864 | Shortest Path to Get All Keys ArrayBit ManipulationBreadth-First SearchMatrix | Hard | 100% | 54.8% | ||
| #488 | Zuma Game StringDynamic ProgrammingStackBreadth-First SearchMemoization | Hard | 100% | 29.5% | ||
| #2360 | Longest Cycle in a Graph Depth-First SearchBreadth-First SearchGraph TheoryTopological SortKosaraju's AlgorithmTarjan's SCC Algorithm | Hard | 88% | 50.9% | ||
| #513 | Find Bottom Left Tree Value TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 88% | 72.4% | ||
| #2101 | Detonate the Maximum Bombs ArrayMathDepth-First SearchBreadth-First SearchGraph TheoryGeometry | Medium | 88% | 50.3% | ||
| #834 | Sum of Distances in Tree Dynamic ProgrammingTreeDepth-First SearchGraph TheoryDP on Trees | Hard | 85% | 65.7% | ||
| #129 | Sum Root to Leaf Numbers TreeDepth-First SearchBinary Tree | Medium | 78% | 70.1% | ||
| #773 | Sliding Puzzle ArrayDynamic ProgrammingBacktrackingBreadth-First SearchMemoizationMatrixHeuristic SearchBidirectional SearchA* Search | Hard | 76% | 74.5% | ||
| #3607 | Power Grid Maintenance ArrayHash TableDepth-First SearchBreadth-First SearchUnion-FindGraph TheoryHeap (Priority Queue)Ordered Set | Medium | 75% | 56.1% | ||
| #222 | Count Complete Tree Nodes Binary SearchBit ManipulationTreeBinary Tree | Medium | 68% | 73.1% | ||
| #765 | Couples Holding Hands GreedyDepth-First SearchBreadth-First SearchUnion-FindGraph Theory | Hard | 63% | 0.6% | ||
| #701 | Insert into a Binary Search Tree TreeBinary Search TreeBinary Tree | Medium | 63% | 73.5% | ||
| #106 | Construct Binary Tree from Inorder and Postorder Traversal ArrayHash TableDivide and ConquerTreeBinary Tree | Medium | 63% | 69.1% | ||
| #94 | Binary Tree Inorder Traversal StackTreeDepth-First SearchBinary Tree | Easy | 50% | 80.3% | ||
| #802 | Find Eventual Safe States Depth-First SearchBreadth-First SearchGraph TheoryTopological SortKosaraju's AlgorithmTarjan's SCC Algorithm | Medium | 50% | 71.2% | ||
| #117 | Populating Next Right Pointers in Each Node II Linked ListTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 50% | 57.8% | ||
| #428 | Serialize and Deserialize N-ary Tree StringTreeDepth-First SearchBreadth-First Search | Hard | 39% | 68.9% | ||
| #1245 | Tree Diameter TreeDepth-First SearchBreadth-First SearchGraph TheoryTopological SortDP on Trees | Medium | 39% | 61.3% | ||
| #1559 | Detect Cycles in 2D Grid ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 100% | 63.4% | ||
| #285 | Inorder Successor in BST TreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 100% | 51.2% | ||
| #2246 | Longest Path With Different Adjacent Characters ArrayStringTreeDepth-First SearchGraph TheoryTopological Sort | Hard | 100% | 0.5% | ||
| #2791 | Count Paths That Can Form a Palindrome in a Tree Hash TableBit ManipulationTreeDepth-First Search | Hard | 100% | 0.5% | ||
| #1087 | Brace Expansion StringBacktrackingStackBreadth-First SearchSorting | Medium | 90% | 66.9% | ||
| #339 | Nested List Weight Sum Depth-First SearchBreadth-First Search | Medium | 88% | 86.0% | ||
| #2096 | Step-By-Step Directions From a Binary Tree Node to Another StringTreeDepth-First SearchBinary TreeBinary LiftingLowest Common Ancestor | Medium | 88% | 56.5% | ||
| #1022 | Sum of Root To Leaf Binary Numbers TreeDepth-First SearchBinary Tree | Easy | 88% | 76.6% | ||
| #2467 | Most Profitable Path in a Tree ArrayTreeDepth-First SearchBreadth-First SearchGraph Theory | Medium | 88% | 67.3% | ||
| #938 | Range Sum of BST TreeDepth-First SearchBinary Search TreeBinary Tree | Easy | 78% | 87.6% | ||
| #366 | Find Leaves of Binary Tree TreeDepth-First SearchBinary TreeDP on Trees | Medium | 77% | 81.3% | ||
| #690 | Employee Importance ArrayHash TableTreeDepth-First SearchBreadth-First Search | Medium | 75% | 69.6% | ||
| #404 | Sum of Left Leaves TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 75% | 62.9% | ||
| #1028 | Recover a Tree From Preorder Traversal StringTreeDepth-First SearchBinary Tree | Hard | 70% | 83.3% | ||
| #2493 | Divide Nodes Into the Maximum Number of Groups Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Hard | 63% | 66.9% | ||
| #993 | Cousins in Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 52% | 59.5% | ||
| #872 | Leaf-Similar Trees TreeDepth-First SearchBinary Tree | Easy | 50% | 70.3% | ||
| #1462 | Course Schedule IV Depth-First SearchBreadth-First SearchGraph TheoryTopological Sort | Medium | 50% | 60.0% | ||
| #1008 | Construct Binary Search Tree from Preorder Traversal ArrayStackTreeBinary Search TreeMonotonic StackBinary Tree | Medium | 38% | 84.4% | ||
| #1020 | Number of Enclaves ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 27% | 72.0% | ||
| #700 | Search in a Binary Search Tree TreeBinary Search TreeBinary Tree | Easy | 25% | 82.9% | ||
| #107 | Binary Tree Level Order Traversal II TreeBreadth-First SearchBinary Tree | Medium | 25% | 68.6% | ||
| #889 | Construct Binary Tree from Preorder and Postorder Traversal ArrayHash TableDivide and ConquerTreeBinary Tree | Medium | 25% | 78.1% | ||
| #1267 | Count Servers that Communicate ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrixCounting | Medium | 25% | 73.5% | ||
| #1367 | Linked List in Binary Tree Linked ListTreeDepth-First SearchBinary Tree | Medium | 100% | 52.0% | ||
| #814 | Binary Tree Pruning TreeDepth-First SearchBinary Tree | Medium | 100% | 72.5% | ||
| #655 | Print Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 100% | 66.7% | ||
| #255 | Verify Preorder Sequence in Binary Search Tree ArrayStackTreeBinary Search TreeRecursionMonotonic StackBinary Tree | Medium | 100% | 51.8% | ||
| #967 | Numbers With Same Consecutive Differences BacktrackingBreadth-First Search | Medium | 77% | 59.3% | ||
| #958 | Check Completeness of a Binary Tree TreeBreadth-First SearchBinary Tree | Medium | 75% | 59.3% | ||
| #2258 | Escape the Spreading Fire ArrayBinary SearchBreadth-First SearchMatrix | Hard | 68% | 0.4% | ||
| #1026 | Maximum Difference Between Node and Ancestor TreeDepth-First SearchBinary Tree | Medium | 63% | 78.2% | ||
| #1443 | Minimum Time to Collect All Apples in a Tree Hash TableTreeDepth-First SearchBreadth-First SearchDP on Trees | Medium | 63% | 63.8% | ||
| #797 | All Paths From Source to Target BacktrackingDepth-First SearchBreadth-First SearchGraph TheoryDirected Acyclic Graph | Medium | 63% | 83.7% | ||
| #2316 | Count Unreachable Pairs of Nodes in an Undirected Graph Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 63% | 0.5% | ||
| #1345 | Jump Game IV ArrayHash TableBreadth-First Search | Hard | 59% | 51.0% | ||
| #1203 | Sort Items by Groups Respecting Dependencies Depth-First SearchBreadth-First SearchGraph TheoryTopological SortDirected Acyclic Graph | Hard | 56% | 66.0% | ||
| #505 | The Maze II ArrayDepth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)MatrixShortest PathDijkstra's AlgorithmHeuristic SearchA* Search | Medium | 54% | 55.2% | ||
| #1466 | Reorder Routes to Make All Paths Lead to the City Zero Depth-First SearchBreadth-First SearchGraph Theory | Medium | 50% | 66.0% | ||
| #2583 | Kth Largest Sum in a Binary Tree TreeBreadth-First SearchSortingBinary Tree | Medium | 39% | 59.0% | ||
| #839 | Similar String Groups ArrayHash TableStringDepth-First SearchBreadth-First SearchUnion-Find | Hard | 38% | 56.4% | ||
| #1382 | Balance a Binary Search Tree Divide and ConquerGreedyTreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 38% | 86.3% | ||
| #1971 | Find if Path Exists in Graph Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Easy | 38% | 55.5% | ||
| #1254 | Number of Closed Islands ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 38% | 67.2% | ||
| #1373 | Maximum Sum BST in Binary Tree Dynamic ProgrammingTreeDepth-First SearchBinary Search TreeBinary TreeDP on Trees | Hard | 38% | 48.1% | ||
| #1339 | Maximum Product of Splitted Binary Tree TreeDepth-First SearchBinary Tree | Medium | 38% | 55.8% | ||
| #2477 | Minimum Fuel Cost to Report to the Capital TreeDepth-First SearchBreadth-First SearchGraph Theory | Medium | 38% | 65.4% | ||
| #894 | All Possible Full Binary Trees Dynamic ProgrammingTreeRecursionMemoizationBinary Tree | Medium | 38% | 82.8% | ||
| #95 | Unique Binary Search Trees II Dynamic ProgrammingBacktrackingTreeBinary Search TreeBinary Tree | Medium | 28% | 62.8% | ||
| #144 | Binary Tree Preorder Traversal StackTreeDepth-First SearchBinary Tree | Easy | 27% | 76.2% | ||
| #145 | Binary Tree Postorder Traversal StackTreeDepth-First SearchBinary Tree | Easy | 25% | 78.5% | ||
| #2236 | Root Equals Sum of Children TreeBinary Tree | Easy | 25% | 85.1% | ||
| #965 | Univalued Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 100% | 73.2% | ||
| #3068 | Find the Maximum Sum of Node Values ArrayDynamic ProgrammingGreedyBit ManipulationTreeSorting | Hard | 100% | 69.4% | ||
| #2608 | Shortest Cycle in a Graph Breadth-First SearchGraph Theory | Hard | 100% | 40.0% | ||
| #3203 | Find Minimum Diameter After Merging Two Trees TreeDepth-First SearchBreadth-First SearchGraph Theory | Hard | 100% | 57.0% | ||
| #1306 | Jump Game III ArrayDepth-First SearchBreadth-First Search | Medium | 100% | 70.3% | ||
| #1036 | Escape a Large Maze ArrayHash TableDepth-First SearchBreadth-First SearchBidirectional Search | Hard | 100% | 36.8% | ||
| #1311 | Get Watched Videos by Your Friends ArrayHash TableBreadth-First SearchGraph TheorySorting | Medium | 89% | 53.5% | ||
| #783 | Minimum Distance Between BST Nodes TreeDepth-First SearchBreadth-First SearchBinary Search TreeBinary Tree | Easy | 88% | 61.6% | ||
| #1298 | Maximum Candies You Can Get from Boxes ArrayBreadth-First SearchGraph Theory | Hard | 88% | 67.2% | ||
| #1034 | Coloring A Border ArrayDepth-First SearchBreadth-First SearchMatrix | Medium | 88% | 0.5% | ||
| #250 | Count Univalue Subtrees TreeDepth-First SearchBinary TreeDP on Trees | Medium | 88% | 57.5% | ||
| #449 | Serialize and Deserialize BST StringTreeDepth-First SearchBreadth-First SearchDesignBinary Search TreeBinary Tree | Medium | 68% | 59.8% | ||
| #1325 | Delete Leaves With a Given Value TreeDepth-First SearchBinary Tree | Medium | 67% | 77.2% | ||
| #426 | Convert Binary Search Tree to Sorted Doubly Linked List Linked ListStackTreeDepth-First SearchBinary Search TreeBinary TreeDoubly-Linked List | Medium | 64% | 65.6% | ||
| #1315 | Sum of Nodes with Even-Valued Grandparent TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 63% | 86.0% | ||
| #1110 | Delete Nodes And Return Forest ArrayHash TableTreeDepth-First SearchBinary Tree | Medium | 63% | 72.5% | ||
| #2192 | All Ancestors of a Node in a Directed Acyclic Graph Depth-First SearchBreadth-First SearchGraph TheoryTopological SortDirected Acyclic Graph | Medium | 63% | 62.3% | ||
| #1676 | Lowest Common Ancestor of a Binary Tree IV Hash TableTreeDepth-First SearchBinary TreeBinary LiftingLowest Common Ancestor | Medium | 63% | 79.6% | ||
| #2577 | Minimum Time to Visit a Cell In a Grid ArrayBreadth-First SearchGraph TheoryHeap (Priority Queue)MatrixShortest Path | Hard | 63% | 56.1% | ||
| #2265 | Count Nodes Equal to Average of Subtree TreeDepth-First SearchBinary Tree | Medium | 53% | 86.8% | ||
| #1644 | Lowest Common Ancestor of a Binary Tree II TreeDepth-First SearchBinary TreeBinary LiftingLowest Common Ancestor | Medium | 51% | 69.7% | ||
| #737 | Sentence Similarity II ArrayHash TableStringDepth-First SearchBreadth-First SearchUnion-Find | Medium | 50% | 51.4% | ||
| #298 | Binary Tree Longest Consecutive Sequence TreeDepth-First SearchBinary TreeDP on Trees | Medium | 50% | 54.8% | ||
| #669 | Trim a Binary Search Tree TreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 42% | 66.8% | ||
| #1970 | Last Day Where You Can Still Cross ArrayBinary SearchDepth-First SearchBreadth-First SearchUnion-FindMatrix | Hard | 41% | 68.7% | ||
| #582 | Kill Process ArrayHash TableTreeDepth-First SearchBreadth-First Search | Medium | 39% | 70.7% | ||
| #865 | Smallest Subtree with all the Deepest Nodes Hash TableTreeDepth-First SearchBreadth-First SearchBinary TreeBinary LiftingLowest Common AncestorDP on Trees | Medium | 39% | 77.6% | ||
| #1123 | Lowest Common Ancestor of Deepest Leaves Hash TableTreeDepth-First SearchBreadth-First SearchBinary TreeBinary LiftingLowest Common AncestorDP on Trees | Medium | 38% | 79.5% | ||
| #847 | Shortest Path Visiting All Nodes Dynamic ProgrammingBit ManipulationBreadth-First SearchGraph TheoryBitmask | Hard | 38% | 66.1% | ||
| #3666 | Minimum Operations to Equalize Binary String MathStringBreadth-First SearchUnion-FindOrdered Set | Hard | 38% | 45.1% | ||
| #2872 | Maximum Number of K-Divisible Components TreeDepth-First Search | Hard | 38% | 74.0% | ||
| #1161 | Maximum Level Sum of a Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 28% | 70.0% | ||
| #3629 | Minimum Jumps to Reach End via Prime Teleportation ArrayHash TableMathBreadth-First SearchNumber Theory | Medium | 28% | 44.6% | ||
| #654 | Maximum Binary Tree ArrayDivide and ConquerStackTreeMonotonic StackBinary TreeCartesian Tree | Medium | 27% | 86.4% | ||
| #1483 | Kth Ancestor of a Tree Node Binary SearchDynamic ProgrammingBit ManipulationTreeDepth-First SearchBreadth-First SearchDesignBinary Lifting | Hard | 27% | 38.9% | ||
| #501 | Find Mode in Binary Search Tree TreeDepth-First SearchBinary Search TreeBinary Tree | Easy | 25% | 59.1% | ||
| #637 | Average of Levels in Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 25% | 75.0% | ||
| #538 | Convert BST to Greater Tree TreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 25% | 71.8% | ||
| #2322 | Minimum Score After Removals on a Tree ArrayBit ManipulationTreeDepth-First Search | Hard | 25% | 76.1% | ||
| #2685 | Count the Number of Complete Components Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 16% | 80.8% | ||
| #2658 | Maximum Number of Fish in a Grid ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 13% | 70.3% | ||
| #364 | Nested List Weight Sum II StackDepth-First SearchBreadth-First Search | Medium | 100% | 67.0% | ||
| #3367 | Maximize Sum of Weights after Edge Removals Dynamic ProgrammingTreeDepth-First SearchSorting | Hard | 100% | 0.3% | ||
| #2617 | Minimum Number of Visited Cells in a Grid ArrayDynamic ProgrammingStackBreadth-First SearchUnion-FindHeap (Priority Queue)MatrixMonotonic Stack | Hard | 100% | 24.0% | ||
| #1391 | Check if There is a Valid Path in a Grid ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 100% | 64.5% | ||
| #563 | Binary Tree Tilt TreeDepth-First SearchBinary TreeDP on Trees | Easy | 100% | 66.1% | ||
| #2039 | The Time When the Network Becomes Idle ArrayBreadth-First SearchGraph Theory | Medium | 100% | 55.8% | ||
| #3067 | Count Pairs of Connectable Servers in a Weighted Tree Network ArrayTreeDepth-First Search | Medium | 100% | 56.2% | ||
| #1993 | Operations on Tree ArrayHash TableTreeDepth-First SearchBreadth-First SearchDesign | Medium | 100% | 45.7% | ||
| #2471 | Minimum Number of Operations to Sort a Binary Tree by Level TreeBreadth-First SearchBinary Tree | Medium | 100% | 74.3% | ||
| #749 | Contain Virus ArrayDepth-First SearchBreadth-First SearchMatrixSimulation | Hard | 100% | 55.1% | ||
| #623 | Add One Row to Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 100% | 64.2% | ||
| #3715 | Sum of Perfect Square Ancestors ArrayHash TableMathTreeDepth-First SearchCountingNumber Theory | Hard | 92% | 42.8% | ||
| #510 | Inorder Successor in BST II TreeBinary Search TreeBinary Tree | Medium | 78% | 61.1% | ||
| #1302 | Deepest Leaves Sum TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 75% | 86.6% | ||
| #2049 | Count Nodes With the Highest Score ArrayTreeDepth-First SearchBinary TreeDP on Trees | Medium | 75% | 52.9% | ||
| #1102 | Path With Maximum Minimum Value ArrayBinary SearchDepth-First SearchBreadth-First SearchUnion-FindHeap (Priority Queue)MatrixDijkstra's Algorithm | Medium | 68% | 54.7% | ||
| #272 | Closest Binary Search Tree Value II Two PointersStackTreeDepth-First SearchBinary Search TreeHeap (Priority Queue)Binary Tree | Hard | 63% | 61.2% | ||
| #671 | Second Minimum Node In a Binary Tree TreeDepth-First SearchBinary Tree | Easy | 63% | 46.2% | ||
| #742 | Closest Leaf in a Binary Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 63% | 47.5% | ||
| #3552 | Grid Teleportation Traversal ArrayHash TableBreadth-First SearchMatrix | Medium | 63% | 23.9% | ||
| #3387 | Maximize Amount After Two Days of Conversions ArrayStringDepth-First SearchBreadth-First SearchGraph Theory | Medium | 60% | 61.7% | ||
| #1038 | Binary Search Tree to Greater Sum Tree TreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 56% | 88.4% | ||
| #1654 | Minimum Jumps to Reach Home ArrayHash TableBreadth-First Search | Medium | 55% | 30.9% | ||
| #514 | Freedom Trail StringDynamic ProgrammingDepth-First SearchBreadth-First Search | Hard | 54% | 59.4% | ||
| #536 | Construct Binary Tree from String StringStackTreeDepth-First SearchBinary Tree | Medium | 50% | 58.7% | ||
| #1530 | Number of Good Leaf Nodes Pairs TreeDepth-First SearchBinary TreeDP on Trees | Medium | 50% | 71.8% | ||
| #1778 | Shortest Path in a Hidden Grid ArrayDepth-First SearchBreadth-First SearchMatrixInteractive | Medium | 40% | 44.7% | ||
| #1522 | Diameter of N-Ary Tree TreeDepth-First SearchDP on Trees | Medium | 38% | 75.5% | ||
| #1609 | Even Odd Tree TreeBreadth-First SearchBinary Tree | Medium | 38% | 67.2% | ||
| #2458 | Height of Binary Tree After Subtree Removal Queries ArrayTreeDepth-First SearchBreadth-First SearchBinary Tree | Hard | 38% | 54.9% | ||
| #530 | Minimum Absolute Difference in BST TreeDepth-First SearchBreadth-First SearchBinary Search TreeBinary Tree | Easy | 29% | 59.5% | ||
| #508 | Most Frequent Subtree Sum Hash TableTreeDepth-First SearchBinary TreeDP on Trees | Medium | 27% | 69.4% | ||
| #1361 | Validate Binary Tree Nodes TreeDepth-First SearchBreadth-First SearchUnion-FindGraph TheoryBinary Tree | Medium | 25% | 44.2% | ||
| #2596 | Check Knight Tour Configuration ArrayDepth-First SearchBreadth-First SearchMatrixSimulation | Medium | 25% | 61.7% | ||
| #606 | Construct String from Binary Tree StringTreeDepth-First SearchBinary Tree | Medium | 25% | 70.8% | ||
| #1506 | Find Root of N-Ary Tree Hash TableBit ManipulationTreeDepth-First Search | Medium | 25% | 78.6% | ||
| #549 | Binary Tree Longest Consecutive Sequence II TreeDepth-First SearchBinary TreeDP on Trees | Medium | 25% | 50.1% | ||
| #919 | Complete Binary Tree Inserter TreeBreadth-First SearchDesignBinary Tree | Medium | 25% | 65.2% | ||
| #1765 | Map of Highest Peak ArrayBreadth-First SearchMatrix | Medium | 25% | 76.0% | ||
| #2421 | Number of Good Paths ArrayHash TableTreeUnion-FindGraph TheorySorting | Hard | 25% | 56.5% | ||
| #3243 | Shortest Distance After Road Addition Queries I ArrayBreadth-First SearchGraph Theory | Medium | 16% | 61.9% | ||
| #3286 | Find a Safe Walk Through a Grid ArrayBreadth-First SearchGraph TheoryHeap (Priority Queue)MatrixShortest Path | Medium | 15% | 55.3% | ||
| #590 | N-ary Tree Postorder Traversal StackTreeDepth-First Search | Easy | 13% | 81.1% | ||
| #3559 | Number of Ways to Assign Edge Weights II ArrayMathDynamic ProgrammingBit ManipulationTreeDepth-First Search | Hard | 13% | 72.5% | ||
| #3310 | Remove Methods From Project Depth-First SearchBreadth-First SearchGraph Theory | Medium | 13% | 0.7% | ||
| #429 | N-ary Tree Level Order Traversal TreeBreadth-First Search | Medium | 13% | 71.6% | ||
| #1932 | Merge BSTs to Create Single BST ArrayHash TableTreeDepth-First SearchBinary Search TreeBinary Tree | Hard | 13% | 39.6% | ||
| #1992 | Find All Groups of Farmland ArrayDepth-First SearchBreadth-First SearchMatrix | Medium | 100% | 75.5% | ||
| #2998 | Minimum Number of Operations to Make X and Y Equal Dynamic ProgrammingBreadth-First SearchMemoization | Medium | 100% | 48.9% | ||
| #3372 | Maximize the Number of Target Nodes After Connecting Trees I TreeDepth-First SearchBreadth-First Search | Medium | 100% | 69.4% | ||
| #3373 | Maximize the Number of Target Nodes After Connecting Trees II TreeDepth-First SearchBreadth-First Search | Hard | 100% | 73.1% | ||
| #2368 | Reachable Nodes With Restrictions ArrayHash TableTreeDepth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 100% | 60.6% | ||
| #776 | Split BST TreeBinary Search TreeRecursionBinary Tree | Medium | 100% | 82.2% | ||
| #3123 | Find Edges in Shortest Paths Depth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)Shortest Path | Hard | 100% | 46.9% | ||
| #928 | Minimize Malware Spread II ArrayHash TableDepth-First SearchBreadth-First SearchUnion-FindGraph Theory | Hard | 100% | 45.8% | ||
| #1457 | Pseudo-Palindromic Paths in a Binary Tree Bit ManipulationTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 100% | 68.4% | ||
| #3710 | Maximum Partition Factor ArrayBinary SearchDepth-First SearchBreadth-First SearchUnion-FindGraph Theory | Hard | 93% | 32.1% | ||
| #2146 | K Highest Ranked Items Within a Price Range ArrayBreadth-First SearchSortingHeap (Priority Queue)Matrix | Medium | 88% | 0.5% | ||
| #1519 | Number of Nodes in the Sub-Tree With the Same Label Hash TableTreeDepth-First SearchBreadth-First SearchCountingDP on Trees | Medium | 88% | 55.5% | ||
| #559 | Maximum Depth of N-ary Tree TreeDepth-First SearchBreadth-First Search | Easy | 88% | 73.7% | ||
| #1104 | Path In Zigzag Labelled Binary Tree MathTreeBinary Tree | Medium | 88% | 75.8% | ||
| #2328 | Number of Increasing Paths in a Grid ArrayDynamic ProgrammingDepth-First SearchBreadth-First SearchGraph TheoryTopological SortMemoizationMatrix | Hard | 88% | 57.3% | ||
| #1600 | Throne Inheritance Hash TableTreeDepth-First SearchDesign | Medium | 88% | 67.4% | ||
| #1377 | Frog Position After T Seconds TreeDepth-First SearchBreadth-First SearchGraph Theory | Hard | 83% | 38.7% | ||
| #3619 | Count Islands With Total Value Divisible by K ArrayDepth-First SearchBreadth-First SearchUnion-FindMatrix | Medium | 79% | 56.2% | ||
| #156 | Binary Tree Upside Down TreeDepth-First SearchBinary Tree | Medium | 75% | 65.5% | ||
| #3004 | Maximum Subtree of the Same Color ArrayDynamic ProgrammingTreeDepth-First Search | Medium | 75% | 58.8% | ||
| #1042 | Flower Planting With No Adjacent Depth-First SearchBreadth-First SearchGraph TheoryGraph Coloring | Medium | 70% | 53.9% | ||
| #675 | Cut Off Trees for Golf Event ArrayBreadth-First SearchHeap (Priority Queue)Matrix | Hard | 63% | 36.6% | ||
| #2204 | Distance to a Cycle in Undirected Graph Depth-First SearchBreadth-First SearchGraph TheoryTopological Sort | Hard | 38% | 73.9% | ||
| #1730 | Shortest Path to Get Food ArrayBreadth-First SearchMatrix | Medium | 38% | 57.3% | ||
| #333 | Largest BST Subtree Dynamic ProgrammingTreeDepth-First SearchBinary Search TreeBinary TreeDP on Trees | Medium | 27% | 45.9% | ||
| #1810 | Minimum Path Cost in a Hidden Grid ArrayDepth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)MatrixInteractiveShortest Path | Medium | 27% | 59.0% | ||
| #1485 | Clone Binary Tree With Random Pointer Hash TableTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 27% | 81.3% | ||
| #2641 | Cousins in Binary Tree II Hash TableTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 27% | 75.9% | ||
| #711 | Number of Distinct Islands II ArrayHash TableDepth-First SearchBreadth-First SearchUnion-FindSortingMatrixHash Function | Hard | 25% | 55.5% | ||
| #1740 | Find Distance in a Binary Tree Hash TableTreeDepth-First SearchBreadth-First SearchBinary TreeBinary LiftingLowest Common Ancestor | Medium | 25% | 74.4% | ||
| #1305 | All Elements in Two Binary Search Trees TreeDepth-First SearchBinary Search TreeSortingBinary Tree | Medium | 25% | 80.3% | ||
| #2290 | Minimum Obstacle Removal to Reach Corner ArrayBreadth-First SearchGraph TheoryHeap (Priority Queue)MatrixShortest Path0-1 BFSDijkstra's Algorithm | Hard | 25% | 70.9% | ||
| #988 | Smallest String Starting From Leaf StringBacktrackingTreeDepth-First SearchBinary Tree | Medium | 25% | 61.3% | ||
| #1145 | Binary Tree Coloring Game TreeDepth-First SearchBinary Tree | Medium | 25% | 53.0% | ||
| #1261 | Find Elements in a Contaminated Binary Tree Hash TableTreeDepth-First SearchBreadth-First SearchDesignBinary Tree | Medium | 25% | 84.1% | ||
| #854 | K-Similar Strings Hash TableStringBreadth-First Search | Hard | 25% | 41.1% | ||
| #3419 | Minimize the Maximum Edge Weight of Graph Binary SearchDepth-First SearchBreadth-First SearchGraph TheoryShortest Path | Medium | 25% | 45.1% | ||
| #3593 | Minimum Increments to Equalize Leaf Paths ArrayDynamic ProgrammingTreeDepth-First Search | Medium | 16% | 41.4% | ||
| #2045 | Second Minimum Time to Reach Destination Breadth-First SearchGraph TheoryShortest PathDijkstra's AlgorithmK Shortest Path | Hard | 13% | 0.6% | ||
| #3558 | Number of Ways to Assign Edge Weights I MathTreeDepth-First Search | Medium | 13% | 64.0% | ||
| #3562 | Maximum Profit from Trading Stocks with Discounts ArrayDynamic ProgrammingTreeDepth-First Search | Hard | 13% | 56.5% | ||
| #897 | Increasing Order Search Tree StackTreeDepth-First SearchBinary Search TreeBinary Tree | Easy | 13% | 79.0% | ||
| #589 | N-ary Tree Preorder Traversal StackTreeDepth-First Search | Easy | 13% | 76.9% | ||
| #1372 | Longest ZigZag Path in a Binary Tree Dynamic ProgrammingTreeDepth-First SearchBinary TreeDP on Trees | Medium | 13% | 67.3% | ||
| #3235 | Check if the Rectangle Corner Is Reachable ArrayMathDepth-First SearchBreadth-First SearchUnion-FindGeometry | Hard | 13% | 25.2% | ||
| #1210 | Minimum Moves to Reach Target with Rotations ArrayBreadth-First SearchMatrix | Hard | 100% | 52.4% | ||
| #2509 | Cycle Length Queries in a Tree ArrayTreeBinary TreeBinary LiftingLowest Common Ancestor | Hard | 100% | 60.6% | ||
| #3376 | Minimum Time to Break Locks I ArrayDynamic ProgrammingBacktrackingBit ManipulationBreadth-First SearchBitmask | Medium | 100% | 32.8% | ||
| #3385 | Minimum Time to Break Locks II ArrayBreadth-First SearchGraph Theory | Hard | 100% | 45.8% | ||
| #2440 | Create Components With Same Value ArrayMathTreeDepth-First SearchEnumeration | Hard | 100% | 53.7% | ||
| #666 | Path Sum IV ArrayHash TableTreeDepth-First SearchBinary Tree | Medium | 100% | 62.9% | ||
| #2005 | Subtree Removal Game with Fibonacci Tree MathDynamic ProgrammingTreeBinary TreeGame TheorySprague–Grundy Theorem | Hard | 100% | 57.8% | ||
| #2846 | Minimum Edge Weight Equilibrium Queries in a Tree ArrayDynamic ProgrammingBit ManipulationTreeDepth-First Search | Hard | 90% | 47.0% | ||
| #2378 | Choose Edges to Maximize Score in a Tree Dynamic ProgrammingTreeDepth-First Search | Medium | 90% | 56.8% | ||
| #1215 | Stepping Numbers MathBacktrackingBreadth-First Search | Medium | 88% | 48.6% | ||
| #1257 | Smallest Common Region ArrayHash TableStringTreeDepth-First SearchBreadth-First SearchBinary LiftingLowest Common Ancestor | Medium | 88% | 68.3% | ||
| #1916 | Count Ways to Build Rooms in an Ant Colony ArrayMathDynamic ProgrammingTreeDepth-First SearchGraph TheoryTopological SortCombinatoricsDP on TreesFermat's Little Theorem | Hard | 88% | 51.8% | ||
| #3787 | Find Diameter Endpoints of a Tree TreeBreadth-First SearchGraph Theory | Medium | 84% | 66.9% | ||
| #3820 | Pythagorean Distance Nodes in a Tree TreeBreadth-First Search | Medium | 78% | 58.0% | ||
| #2920 | Maximum Points After Collecting Coins From All Nodes ArrayDynamic ProgrammingBit ManipulationTreeDepth-First SearchMemoizationDP on Trees | Hard | 75% | 36.9% | ||
| #3383 | Minimum Runes to Add to Cast Spell ArrayDepth-First SearchBreadth-First SearchGraph TheoryTopological Sort | Hard | 75% | 44.7% | ||
| #1284 | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix ArrayHash TableBit ManipulationBreadth-First SearchMatrix | Hard | 75% | 72.9% | ||
| #3575 | Maximum Good Subtree Score ArrayDynamic ProgrammingBit ManipulationTreeDepth-First SearchBitmask | Hard | 75% | 45.7% | ||
| #2612 | Minimum Reverse Operations ArrayHash TableBreadth-First SearchUnion-FindOrdered Set | Hard | 75% | 17.2% | ||
| #2445 | Number of Nodes With Value One ArrayTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 75% | 66.3% | ||
| #2867 | Count Valid Paths in a Tree MathDynamic ProgrammingTreeDepth-First SearchNumber TheoryPrimality TestSieve TheoryPrime Number Sieve | Hard | 64% | 36.6% | ||
| #3015 | Count the Number of Houses at a Certain Distance I Breadth-First SearchGraph TheoryPrefix Sum | Medium | 63% | 58.1% | ||
| #3939 | Count Non Adjacent Subsets in a Rooted Tree ArrayDynamic ProgrammingTreeDepth-First Search | Hard | 63% | 56.1% | ||
| #3515 | Shortest Path in a Weighted Tree ArrayTreeDepth-First SearchBinary Indexed TreeSegment Tree | Hard | 56% | 42.6% | ||
| #3313 | Find the Last Marked Nodes in Tree TreeDepth-First Search | Hard | 55% | 56.5% | ||
| #3528 | Unit Conversion I Depth-First SearchBreadth-First SearchGraph Theory | Medium | 52% | 54.1% | ||
| #1719 | Number Of Ways To Reconstruct A Tree ArrayHash TableTreeGraph TheorySimulation | Hard | 50% | 46.2% | ||
| #3481 | Apply Substitutions ArrayHash TableStringDepth-First SearchBreadth-First SearchGraph TheoryTopological Sort | Medium | 43% | 77.9% | ||
| #2673 | Make Costs of Paths Equal in a Binary Tree ArrayDynamic ProgrammingGreedyTreeBinary Tree | Medium | 39% | 58.8% | ||
| #672 | Bulb Switcher II MathBit ManipulationDepth-First SearchBreadth-First Search | Medium | 38% | 50.4% | ||
| #3772 | Maximum Subgraph Score in a Tree ArrayDynamic ProgrammingTreeDepth-First Search | Hard | 29% | 71.0% | ||
| #1628 | Design an Expression Tree With Evaluate Function ArrayMathStackTreeDesignBinary Tree | Medium | 28% | 82.5% | ||
| #1273 | Delete Tree Nodes ArrayTreeDepth-First SearchBreadth-First SearchDP on Trees | Medium | 27% | 61.6% | ||
| #1469 | Find All The Lonely Nodes TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 27% | 84.1% | ||
| #3157 | Find the Level of Tree with Minimum Sum TreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 27% | 69.5% | ||
| #1379 | Find a Corresponding Node of a Binary Tree in a Clone of That Tree TreeDepth-First SearchBreadth-First SearchBinary Tree | Easy | 27% | 85.9% | ||
| #1586 | Binary Search Tree Iterator II StackTreeDesignBinary Search TreeBinary TreeIterator | Medium | 25% | 63.5% | ||
| #998 | Maximum Binary Tree II TreeBinary Tree | Medium | 25% | 70.7% | ||
| #1973 | Count Nodes Equal to Sum of Descendants TreeDepth-First SearchBinary Tree | Medium | 25% | 77.3% | ||
| #3535 | Unit Conversion II ArrayMathDepth-First SearchBreadth-First SearchGraph Theory | Medium | 25% | 65.8% | ||
| #1214 | Two Sum BSTs Two PointersBinary SearchStackTreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 25% | 68.2% | ||
| #1080 | Insufficient Nodes in Root to Leaf Paths TreeDepth-First SearchBinary Tree | Medium | 25% | 55.4% | ||
| #2973 | Find Number of Coins to Place in Tree Nodes Dynamic ProgrammingTreeDepth-First SearchSortingHeap (Priority Queue)DP on Trees | Hard | 25% | 37.7% | ||
| #3786 | Total Sum of Interaction Cost in Tree Groups ArrayTreeDepth-First Search | Hard | 25% | 54.4% | ||
| #663 | Equal Tree Partition TreeDepth-First SearchBinary Tree | Medium | 25% | 42.3% | ||
| #1120 | Maximum Average Subtree TreeDepth-First SearchBinary Tree | Medium | 25% | 67.0% | ||
| #1490 | Clone N-ary Tree Hash TableTreeDepth-First SearchBreadth-First Search | Medium | 25% | 83.2% | ||
| #1597 | Build Binary Expression Tree From Infix Expression StringStackTreeBinary Tree | Hard | 25% | 62.9% | ||
| #3327 | Check if DFS Strings Are Palindromes ArrayHash TableStringTreeDepth-First SearchHash Function | Hard | 25% | 20.8% | ||
| #331 | Verify Preorder Serialization of a Binary Tree StringStackTreeBinary Tree | Medium | 25% | 47.5% | ||
| #2476 | Closest Nodes Queries in a Binary Search Tree ArrayBinary SearchTreeDepth-First SearchBinary Search TreeBinary Tree | Medium | 25% | 44.7% | ||
| #2556 | Disconnect Path in a Binary Matrix by at Most One Flip ArrayDynamic ProgrammingDepth-First SearchBreadth-First SearchMatrix | Medium | 25% | 28.0% | ||
| #302 | Smallest Rectangle Enclosing Black Pixels ArrayBinary SearchDepth-First SearchBreadth-First SearchMatrix | Hard | 25% | 61.0% | ||
| #2331 | Evaluate Boolean Binary Tree TreeDepth-First SearchBinary Tree | Easy | 25% | 82.4% | ||
| #685 | Redundant Connection II Depth-First SearchBreadth-First SearchUnion-FindGraph Theory | Hard | 25% | 36.4% | ||
| #1096 | Brace Expansion II Hash TableStringBacktrackingStackBreadth-First SearchSorting | Hard | 25% | 63.9% | ||
| #2059 | Minimum Operations to Convert Number ArrayBreadth-First Search | Medium | 25% | 52.0% | ||
| #1516 | Move Sub-Tree of N-Ary Tree TreeDepth-First Search | Hard | 25% | 59.8% | ||
| #1602 | Find Nearest Right Node in Binary Tree TreeBreadth-First SearchBinary Tree | Medium | 25% | 75.1% | ||
| #1612 | Check If Two Expression Trees are Equivalent Hash TableTreeDepth-First SearchBinary TreeCounting | Medium | 25% | 71.8% | ||
| #1660 | Correct a Binary Tree Hash TableTreeDepth-First SearchBreadth-First SearchBinary Tree | Medium | 25% | 74.3% | ||
| #1666 | Change the Root of a Binary Tree TreeDepth-First SearchBinary Tree | Medium | 25% | 75.0% | ||
| #1766 | Tree of Coprimes ArrayMathTreeDepth-First SearchNumber Theory | Hard | 25% | 44.4% | ||
| #2174 | Remove All Ones With Row and Column Flips II ArrayBit ManipulationBreadth-First SearchMatrix | Medium | 25% | 67.4% | ||
| #2313 | Minimum Flips in Binary Tree to Get Result Dynamic ProgrammingTreeDepth-First SearchBinary Tree | Hard | 25% | 57.0% | ||
| #2689 | Extract Kth Character From The Rope Tree TreeDepth-First SearchBinary Tree | Easy | 25% | 73.3% | ||
| #2925 | Maximum Score After Applying Operations on a Tree Dynamic ProgrammingTreeDepth-First SearchDP on Trees | Medium | 25% | 47.5% | ||
| #3690 | Split and Merge Array Transformation ArrayHash TableBreadth-First Search | Medium | 13% | 58.9% | ||
| #3493 | Properties Graph ArrayHash TableDepth-First SearchBreadth-First SearchUnion-FindGraph Theory | Medium | 13% | 49.1% | ||
| #3568 | Minimum Moves to Clean the Classroom ArrayHash TableBit ManipulationBreadth-First SearchMatrix | Medium | 13% | 26.9% | ||
| #1263 | Minimum Moves to Move a Box to Their Target Location ArrayBreadth-First SearchHeap (Priority Queue)Matrix | Hard | 13% | 49.9% | ||
| #3585 | Find Weighted Median Node in Tree ArrayBinary SearchDynamic ProgrammingBit ManipulationTreeDepth-First Search | Hard | 13% | 26.2% | ||
| #3319 | K-th Largest Perfect Subtree Size in Binary Tree TreeDepth-First SearchSortingBinary Tree | Medium | 13% | 62.4% | ||
| #3486 | Longest Special Path II ArrayHash TableTreeDepth-First SearchPrefix Sum | Hard | 13% | 19.8% | ||
| #3283 | Maximum Number of Moves to Kill All Pawns ArrayMathBit ManipulationBreadth-First SearchGame TheoryBitmask | Hard | 13% | 34.2% | ||
| #2277 | Closest Node to Path in Tree ArrayTreeDepth-First SearchBreadth-First Search | Hard | 13% | 62.5% | ||
| #499 | The Maze III ArrayStringDepth-First SearchBreadth-First SearchGraph TheoryHeap (Priority Queue)MatrixShortest PathDijkstra's AlgorithmHeuristic SearchA* Search | Hard | 13% | 52.5% |
Showing 382 of 382 problems in Tree Breadth-First Search (BFS)Filtered: All Companies