title-img


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 →

Poisonous Plants

There are a number of plants in a garden. Each of the plants has been treated with some amount of pesticide. After each day, if any plant has more pesticide than the plant on its left, being weaker than the left one, it dies. You are given the initial values of the pesticide in each of the plants. Determine the number of days after which no plant dies, i.e. the time after which there is no plant with more pesticide content than the plant to its left. Example p = [ 3, 6, 2, 7, 5 ] // pe

View Solution →

Roads and Libraries

Determine the minimum cost to provide library access to all citizens of HackerLand. There are n cities numbered from 1 to n. Currently there are no libraries and the cities are not connected. Bidirectional roads may be built between any city pair listed in cities. A citizen has access to a library if: 1. Their city contains a library. 2. They can travel by road from their city to a city containing a library. unction Description Complete the function roadsAndLibraries in the editor be

View Solution →

Find the nearest clone

In this challenge, there is a connected undirected graph where each of the nodes is a color. Given a color, find the shortest path connecting any two nodes of that color. Each edge has a weight of . If there is not a pair or if the color is not found, print -1. Function Description Complete the findShortest function in the editor below. It should return an integer representing the length of the shortest path between two nodes of the same color, or -1 if it is not possible. findShorte

View Solution →

Designer PDF Viewer

When a contiguous block of text is selected in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example: There is a list of 26 character heights aligned by index to their letters. For example, 'a' is at index 0 and 'z' is at index 05. There will also be a string. Using the letter heights given, determine the area of the rectangle highlight in mm^2 assuming all letters are 1mm wide. Example h = [1, 3, 1, 3, 1

View Solution →