Looking for good programming challenges?

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

All posts tagged algorithms

Coin in Line

Problem Statement A and B are playing a game. At the beginning there are n coins. Given two more numbers x and y. In each move a player can pick x or y or 1 coins. A always starts the game. The player who picks the last coin wins the game. For . . . Read more

Replace And Remove

Problem Statement Consider the following two rules that are to be applied to strings over the alphabets: [‘a’, ‘b’, ‘c’, ‘d’] Replace each ‘a’ with ‘dd’ Delete each ‘b’ Solution

Out of Boundary Paths

Problem Statement There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary in four directions (up, down, left, right). However, you can at most move N times. Find out . . . Read more

Unique Paths II

Problem Statement A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ . . . Read more

Minimum Swaps To Make Sequences Increasing

Problem Statement We have two integer sequences A and B of the same non-zero length. We are allowed to swap elements A[i] and B[i]. Note that both elements are in the same index position in their respective sequences. At the end of some number of swaps, A and B are . . . Read more

Pascal Triangle

Problem StatementThe figure below illustrates the first five rows of a graphic that is known as Pascal’s triangle. Each entry in each row before the last one is adjacent to one or two numbers in the lower row. It is a fact that each entry holds the sum of the . . . Read more

Target Sum

Problem Statement You are given a list of non-negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and – as its new symbol. Find out how many ways to assign symbols to . . . Read more

Number of Dice Rolls With Target Sum

Problem Statement You have d dice, and each die has f faces numbered 1, 2, …, f. Return the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals target. Example 1 Input: d . . . Read more

Coin Change

Problem Statement You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return . . . Read more

Partition List

Problem Statment Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions. Example Input: head = 1->4->3->2->5->2, x . . . Read more