Showing 7 questions
Implement an iterator that cycles through multiple lists in a zigzag pattern. The iterator should return elements from each list in turn until all elements are exhausted.
#1. Zigzag Iterator
You are given a grid of oranges, some fresh, some rotten. Rotten oranges contaminate adjacent fresh oranges; find the minimum time until all oranges are rotten.
#2. Rotting Oranges
Given an array representing the height of bars, calculate how much water can be trapped between them after rain. Think about finding the maximum height to the left and right of each bar.
#3. Trapping Rain Water
You are given an array representing the heights of vertical lines. Find two lines that, together with the x-axis, form a container that holds the most water.
#4. Container With Most Water
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#5. Valid Parentheses
Given an array of side lengths, find the largest perimeter of a triangle that can be formed. Return 0 if no such triangle exists.
#6. Largest Perimeter Triangle
Traverse a given matrix in a spiral pattern, returning all elements in the order you visit them. Essentially, walk around the matrix layer by layer, adding elements to a list.
#7. Spiral Matrix