Markov takes out his Snakes and Ladders game, stares at the board and wonders: "If I can always roll the die to whatever number I want, what would be the least number of rolls to reach the destination?" RulesThe game is…
You are given a tree (a simple connected graph with no cycles). Find the maximum number of edges you can remove from the tree to get a forest such that each connected component of the forest contains an even number of…
Consider an undirected graph where each edge is the same weight. Each of the nodes is labeled consecutively. You will be given a number of queries. For each query, you will be given a list of edges describing an…
The member states of the UN are planning to send people to the moon. They want them to be from different countries. You will be given a list of pairs of astronaut ID's. Each pair is made of astronauts from the same…
The Ruler of HackerLand believes that every citizen of the country should have access to a library. Unfortunately, HackerLand was hit by a tornado that destroyed all of its libraries and obstructed its roads! As you are…
Consider a matrix where each cell contains either a or a . Any cell containing a is called a filled cell. Two cells are said to be connected if they are adjacent to each other horizontally, vertically, or diagonally. In…
You will be given an array of integers and a target value. Determine the number of pairs of array elements that have a difference equal to a target value. For example, given an array of [1, 2, 3, 4] and a target value…
Lauren has a chart of distinct projected prices for a house over the next several years. She must buy the house in one year and sell it in another, and she must do so at a loss. She wants to minimize her financial loss…
The city of Gridland is represented as an matrix where the rows are numbered from to and the columns are numbered from to . Gridland has a network of train tracks that always run in straight horizontal lines along a…
Hackerland is a one-dimensional city with houses aligned at integral locations along a road. The Mayor wants to install radio transmitters on the roofs of the city's houses. Each transmitter has a fixed range meaning it…
A gene is represented as a string of length (where is divisible by ), composed of the letters , , , and . It is considered to be steady if each of the four letters occurs exactly times. For example, and are both steady…
A string is said to be a child of a another string if it can be formed by deleting 0 or more characters from the other string. Given two strings of equal length, what's the longest string that can be constructed such…
Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other. For…
Palindromes are strings that read the same from the left or right, for example madam or 0110. You will be given a string representation of a number and a maximum number of changes you can make. Alter the string, one…
Sherlock considers a string to be valid if all characters of the string appear the same number of times. It is also valid if he can remove just character at index in the string, and the remaining characters will occur…
HackerLand National Bank has a simple policy for warning clients about possible fraudulent account activity. If the amount spent by a client on a particular day is greater than or equal to the client's median spending…
In this challenge you need to print the string that accompanies each integer in a list sorted by the integers. If two strings are associated with the same integer, they must be printed in their original order so your…
Given an array of integers, determine whether the array can be sorted in ascending order using only one of the following operations one time. Swap two elements. Reverse one sub-segment. Determine whether one, both or…
Larry has been given a permutation of a sequence of natural numbers incrementing from as an array. He must determine whether the array can be sorted using the following operation any number of times: Choose any…
Ema built a quantum computer! Help her test its capabilities by solving the problem below. Given a grid of size , each cell in the grid is either or . A valid plus is defined here as the crossing of two segments…