Graphs

Algorithms

Sliding Puzzle

A 2x3 puzzle board has tiles numbered 1 to 5 and an empty square represented by 0. A move consists of swapping 0 with an adjacent number. The puzzle is solved when [[1, 2, 3], [4, 5, 0]] is achieved. Given a puzzle configuration, return the least number of moves required to solve it.

Read
Algorithms

Detecting Arbitrage in Foreign Exchange Markets

Suppose you are given a 2D matrix representing exchange rates between currencies. You want to determine if arbitrage exists in the market (i.e. if there is a way to start with a single unit of some currency C and convert it back to more than one unit of C through a sequence of exchanges).

Read
Algorithms

Optimising Highway Networks

Write a program which takes an existing highway network (specified as a set of highway sections between pairs of cities) and proposals for new highway sections, and returns the proposed highway section which leads to the most improvement in the total driving distance.

Read
Algorithms

Finding Bridges in a Graph

There are n servers in a network, connected by undirected server-to-server connections. A critical connection is a connection that, if removed, will make some server unable to reach some other server. Find all critical connections.

Read
Algorithms

Connecting Cities At Minimum Cost

There are N cities. You are given an array of connections. Each connection describes the cost of connecting one city to another. Return the minimum cost required to ensure that every pair of cities is connected by a path of connections.

Read
Algorithms

Alien Dictionary

I embark on a month-long journey to blog about one interesting algorithmic problem a day. I start by diving into the commonly-feared Alien Dictionary problem.

Read