Looking for good programming challenges?

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

All posts tagged algorithms

Angry children 2 challenge

Problem statement Bill Gates is on one of his philanthropic journeys to a village in Utopia. He has packets of candies and would like to distribute one packet to each of the children in the village (each packet may contain different number of candies). To avoid a fight between the . . . Read more

Lily’s homework challenge

Problem statement Whenever George asks Lily to hang out, she’s busy doing homework. George wants to help her finish it faster, but he’s in over his head! Can you help George understand Lily’s homework so she can hang out with him? Consider an array of distinct integers, . George can . . . Read more

House robber 2 challenge

Problem statement After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a circle. That means the first house is the neighbor of . . . Read more

House robber challenge

Problem statement You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two . . . Read more

Fraudulent activity notifications challenge

Problem statement The 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 for the last days, they send the client a notification about potential . . . Read more

Counting sort

Problem statement In this challenge you need to print the data that accompanies each integer in a list. In addition, if two strings have the same integers, you need to print the strings in their original order. Hence, your sorting algorithm should be stable, i.e. the original order should be . . . Read more

Implement the `cd` command

Problem statement Implement the cd command i.e. given a function cd(‘a/b’,’c/../d/e/../f’), where 1st param is current directory and 2nd param is the sequence of operations, find the final directory that the user will be in when the cd command is executed. Solution I am going to use a Stack to . . . Read more

Next greater element in array

Problem statement Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element is the first greater element on the right side of in array. Elements for which no greater element exist, consider next greater element as . For the input array . . . Read more

Buy and sell a stock k times

Problem statement Write a program to compute the maximum profit that can be made by buying and selling a share times over a given day range. Your program takes and an array of daily stock prices as input. Solution At any given day you can either make a transaction or . . . Read more