Looking for good programming challenges?

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

All posts in Algorithms

Mud Walls

Problem Statement A child likes to build mud walls by placing mud between sticks positioned on a number line. The gap between sticks will be referred to as a cell, and each cell will contain one segment of wall. The height of mud in a segment cannot exceed 1 unit . . . Read more

Weird Faculty

Problem Statement This semester you are taking a course taught by a faculty member who has a weird way of grading tests. In a test, n questions will be asked, and the correctness of the answers is already determined. For the ith question, the verdict will be v[i] (where 0 . . . Read more

Longest Subarray

Problem Statement A subarray of array a is defined as a contiguous block of a’s elements having a length that is less than or equal to the length of the array. For example, the subarrays of array a = [1, 2, 3] are [1], [2], [3], [1, 2], [2, 3], . . . Read more

Maximum Difference in an Array

Problem Statement You are given an array of integers and must compute the maximum difference between any item and any lower indexed smaller item for all the possible pairs, i.e., for a given array ‘a’, find the maximum value of a[j] – a[i] for all i, j where 0 ≤ . . . Read more

Fun with Anagrams

Problem Statement Two strings are anagrams if they are permutations of each other. For example, “aaagmnrs” is an anagram of “anagrams”. Given an array of strings, remove each string that is an anagram of an earlier string, then return the remaining array in sorted order. For example, given the strings . . . Read more

Special Palindrome Again Challenge

Problem Statement A string is said to be a special palindromic string if either of two conditions is met: * All of the characters are the same, e.g. aaa. * All characters except the middle one are the same, e.g. aadaa. A specialpalindromic substring is any substring of a string . . . Read more

Making Anagrams Challenge

Problem Statement Alice is taking a cryptography class and finding anagrams to be very useful. We consider two strings to be anagrams of each other if the first string’s letters can be rearranged to form the second string. In other words, both strings must contain the same exact letters in . . . Read more

Counting Inversions Challenge

Problem Statement In an array, , the elements at indices and (where ) form an inversion if . In other words, inverted elements and are considered to be “out of order”. To correct an inversion, we can swap adjacent elements. For example, consider the dataset . It has two inversions: . . . Read more

Frequency Queries

Problem Statement You are given queries. Each query is of the form two integers described below: – : Insert x in your data structure. – : Delete one occurence of y from your data structure, if present. – : Check if any integer is present whose frequency is exactly . . . . Read more

Count Triplets Challenge

You are given an array and you need to find number of tripets of indices such that the elements at those indices are in geometric progression for a given common ratio and . For example, . If , we have and at indices and . Function Description Complete the countTriplets . . . Read more