dsa2 min read
Decode String — Stack for Counts and Strings
Decode a string with nested encodings like 3[a2[bc]] using two stacks: one for counts and one for partial strings.
Read →
webcoderspeed.com
1276 articles
Decode a string with nested encodings like 3[a2[bc]] using two stacks: one for counts and one for partial strings.
Evaluate an RPN expression by pushing numbers and applying operators to the top two stack elements.
Find the maximum in each sliding window of size k using a monotonic decreasing deque storing indices.
Simulate asteroid collisions using a stack where right-moving asteroids wait and left-moving ones destroy smaller ones.
Sum the minimums of all subarrays by computing each element's contribution as the minimum using previous and next smaller element spans.