title-img


Balanced Brackets

A bracket is considered to be any one of the following characters: (, ), {, }, [, or ]. Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {) occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type. There are three types of matched pairs of brackets: [], {}, and (). A matching pair of brackets is not balanced if the set of brackets it encloses are not matched. For example, {[(])} is not balanced because the contents in betwe

View Solution →

Queues: A Tale of Two Stacks

A queue is an abstract data type that maintains the order in which elements were added to it, allowing the oldest elements to be removed from the front and new elements to be added to the rear. This is called a First-In-First-Out (FIFO) data structure because the first element added to the queue (i.e., the one that has been waiting the longest) is always the first one to be removed. A basic queue has the following operations: Enqueue: add a new element to the end of the queue. Dequeue: re

View Solution →

Largest Rectangle

Skyline Real Estate Developers is planning to demolish a number of old, unoccupied buildings and construct a shopping mall in their place. Your task is to find the largest solid area in which the mall can be constructed. There are a number of buildings in a certain two-dimensional landscape. Each building has a height, given by h[ i ] where i [ 1, n ]. If you join k adjacent buildings, they will form a solid rectangle of area . For example, the heights array . A rectangle of height and l

View Solution →

Min Max Riddle

Given an integer array of size n, find the maximum of the minimum(s) of every window size in the array. The window size varies from 1 to n. For example, given arr = [6, 3 , 5 , 1, 12 ] consider window sizes of 1 through 5. Windows of size are . The maximum value of the minimum values of these windows is . Windows of size are and their minima are ( 3, 3, 1, 1 ). The maximum of these values is . Continue this process through window size to finally consider the entire array. All of the ans

View Solution →

Castle on the Grid

You are given a square grid with some cells open (.) and some blocked (X). Your playing piece can move along any row or column until it reaches the edge of the grid or a blocked cell. Given a grid, a start and a goal, determine the minmum number of moves to get to the goal. Function Description Complete the minimumMoves function in the editor. minimumMoves has the following parameter(s): string grid[n]: an array of strings that represent the rows of the grid int startX: starting X c

View Solution →