Looking for good programming challenges?

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

Boyer–Moore string search algorithm

The Boyer–Moore string search algorithm is an efficient string searching algorithm that is the standard benchmark for practical string search literature. For instance, GNU grep uses the Boyer-Moore algorithm. For a full explanation of the algorithm please refer to Wikipedia.

Aho-Corasick string search algorithm

The Aho–Corasick algorithm is a string searching algorithm invented by Alfred V. Aho and Margaret J. Corasick. For a full explanation of the algorithm please refer to Wikipedia.

Read CSV – Java

The following code reads a CSV file and converts it to List<Map<String, String>> in Java. Each row is represented by a Map<String, String> entry in the resulting List. Map<String, String> maps column name (header value) to value.

Merge intervals

Problem statement Given a collection of intervals, merge all overlapping intervals. Sample Input

Output

Solution Concept We sort the intervals by decreasing order of start times. That way we can quickly check if intervals overlap or not by comparing start time of previous interval with end time of . . . Read more

Ema’s Supercomputer challenge

Problem statement 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 (horizontal and vertical) of equal lengths. . . . Read more

Abbreviation challenge

Problem statement You can perform the following operation on some string, : 1. Capitalize zero or more of ‘s lowercase letters at some index i (i.e., make them uppercase). 2. Delete all of the remaining lowercase letters in . Given queries in the form of two strings, and , determine . . . Read more

Goodland Electricity challenge – O(n)

In the previous post I discussed an algorithm that had a running time of . Well here is an algorithm to the Goodland Electricity challenge. Greedy algorithm For each city i store its preceding tower in previousTowerFor[i]. If i has a tower then previousTowerFor[i] = i. If no tower precedes, . . . Read more

Reverse words in string

Problem statement Given an input string, reverse the string word by word. For example, given s = “the sky is blue”, return “blue is sky the”. Solution algorithm Write a function reverse(string, start, end) that reverses string[start:end]. Reverse entire input string. Iterate over (reversed)words in reversed string and correct them . . . Read more

Goodland Electricity challenge

Problem statement Goodland is a country with cities, and each city is sequentially numbered from to . These cities are connected by roads, and each road connects city to its neighboring city, . The distance between any two cities and is . Goodland’s government started a project to improve the . . . Read more