dsa1 min read
Score of Parentheses — Stack Depth Doubling
Calculate the score of balanced parentheses where () = 1 and AB = A+B and (A) = 2*A using a stack depth trick.
Read →
webcoderspeed.com
1276 articles
Calculate the score of balanced parentheses where () = 1 and AB = A+B and (A) = 2*A using a stack depth trick.
Find the minimum intervals to execute all tasks with cooldown n by greedily scheduling the most frequent task first.
Find minutes until all oranges rot using multi-source BFS starting from all initially rotten oranges simultaneously.
Count islands in a 2D grid using BFS or DFS to flood-fill connected land cells, marking them visited.
Detect if all courses can be finished (no cycle) using Kahn's algorithm: BFS on in-degree zero nodes.