Hoarding programming problems for you!

Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

Archive for January 2017

Summary ranges challenge

Problem statement Given a sorted integer array without duplicates, return the summary of its ranges for consecutive numbers. For example, given , return . Solution

Search for a range challenge

Problem statement Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of . If the target is not found in the array, return . For example, given and target value 8, return . . . . Read more

Minimum window substring challenge

Given a string and a string , find the minimum window in which will contain all the characters in in complexity . Sample Input 0

Sample Output 0

Solution The first step we are going to take is, count the occurrences of each letter in string . We . . . Read more

Append and delete challenge

Problem statement You have a string, , of lowercase English alphabetic letters. You can perform two types of operations on : Append a lowercase English alphabetic letter to the end of the string. Delete the last character in the string. Performing this operation on an empty string results in an . . . Read more

Mini-max sum challenge

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Input Format A single line of five space-separated integers. Constraints Each . . . Read more

Kangaroo challenge

There are two kangaroos on an x-axis ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location and moves at a rate of meters per jump. The second kangaroo starts at location and moves at a rate of meters per jump. Given the . . . Read more

The Knuth shuffle

The Knuth shuffle algorithm is an algorithm for randomly shuffling the elements of an array arr of size given a function that generates a uniformly distributed random number in time. The algorithm produces an unbiased permutation. That is, every permutation is equally likely.

Proof that the algorithm is unbiased . . . Read more

Beautiful quadruples challenge

Problem statement We call an quadruple of positive integers, , beautiful if the following condition is true: Note: is the bitwise XOR operator. Given and , count the number of beautiful quadruples of the form where the following constraints hold: When you count the number of beautiful quadruples, you should . . . Read more

Sort hotel list challenge

Problem statement Given a set of hotels and its guests reviews, sort the hotels based on a list of words specified by a user. The criteria to sort the hotels should be how many times the words specified by the user is mentioned in the hotel reviews. Input The first . . . Read more

Delta encoding challenge

Problem statement Given a list of numbers, e.g.:

Output a delta encoding for the sequence. In a delta encoding, the first element is reproduced as is. Each subsequent element is represented as the numeric difference from the element before it. E.g. for the sequence above, the delta encoding would . . . Read more