Practice · 9 problems
Stack
0 of 9 solved on this device
- 014Valid ParenthesesGiven a string `s` containing only the characters '()[]{}', determine whether the input is valid: brackets must close in the correct order and be of the same type.Easy
- 015Min StackDesign a stack supporting push, pop, top and retrieving the minimum element, EVERY operation in O(1) time. Implement the MinStack class with push(val), pop(), top() and getMin().Medium
- 016Largest Rectangle in HistogramGiven an array `heights` representing a histogram's bar heights where each bar has width 1, return the area of the largest rectangle that fits inside the histogram.Hard
- 060Next Greater Element IYou are given two distinct-valued arrays where `nums1` is a subset of `nums2`. For each value in nums1, find the first element to its right in nums2 that is greater than it; if none exists, use -1. Return these answers in order.Easy
- 061Evaluate Reverse Polish NotationEvaluate an arithmetic expression given in Reverse Polish Notation as an array of tokens. Valid operators are +, -, *, /. Division truncates toward zero.Medium
- 062Daily TemperaturesGiven an array `temperatures`, return an array `answer` where answer[i] is the number of days you must wait after day i for a warmer temperature. If no warmer day exists, answer[i] is 0.Medium
- 104Decode StringGiven an encoded string of the form k[encoded_string], meaning the bracketed string repeats exactly k times, return its decoded form. Brackets may be nested.Medium
- 105Asteroid CollisionAn array `asteroids` gives asteroid sizes; the sign is the direction (positive means right, negative left). Colliding asteroids destroy the smaller one, or both if equal. Asteroids moving the same way never meet. Return the final state.Medium
- 106Car FleetCars are at various positions heading to the same `target`, each with its own speed. A faster car catches a slower one and they travel on together as a fleet at the slower speed. Return how many fleets arrive at the destination.Medium