Algorithms

Algorithms

Smaller Numbers After Self

You are given an integer array A and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of A[i].

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

Regular Expression Matching

Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*'.

Read
Algorithms

The Skyline Problem

A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Suppose you are given the locations and height of all the buildings in a cityscape. Write a program to output the skyline formed by these buildings.

Read
Algorithms

Validating K-Palindromes

Given a string s and an integer k, find out if the given string is a k-palindrome or not. A string is a k-palindrome if it can be transformed into a palindrome by removing at most k characters from it.

Read
Algorithms

Kth Smallest Element in Two Sorted Arrays

Given two sorted arrays, find the kth smallest element in the array that would be produced if we combined and sorted them. Array elements may be duplicated within and across the input arrays.

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