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
Algorithms

Trapping Rain Water (2D)

Given an n x m matrix of positive integers representing the height of each cell in a 2D elevation map, compute the amount of water that can be trapped within it.

Read
Algorithms

Trapping Rain Water

Given an array of non-negative integers that represent an elevation map where the width of each bar is 1, compute the amount of rainwater that can be trapped within it.

Read
Algorithms

Largest Rectangle In Histogram

Given an array of non-negative integers which represent histogram bar heights, find the area of largest rectangle.

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