Problem at https://www.hackerrank.com/challenges/restaurant/problem Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size into smaller identical pieces such that each piece is a square having maximum possible side length with no left over piece of bread. Input Format The first line contains an integer . lines follow. EachContinue reading “Restaurant”
Category Archives: Uncategorized
Sparse Arrays
There is a collection of input strings and a collection of query strings. For each query string, determine how many times it occurs in the list of input strings. Return an array of the results. Example
Array Manipulation
Starting with a 1-indexed array of zeros and a list of operations, for each operation add a value to each of the array element between two given indices, inclusive. Once all operations have been performed, return the maximum value in the array. Example Queries are interpreted as follows: a b k 1 5 3 4Continue reading “Array Manipulation”
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 ofContinue reading “Balanced Brackets”