## Substring Diff | HackerRank (Algorithms) | Longest Common Substring

Problem In this problem, we’ll use the term “longest common substring” loosely. It refers to substrings differing at some number or fewer characters when compared index by index. For example, ‘abc’ and ‘adc’ differ in one position, ‘aab’ and ‘aba’ differ in two. Given two strings and an integer , determine the […]

## Hotel Bytelandia Solution

Hotel Bytelandia Solution – A number of guests have made reservations. Each reservation consists of an arrival time, and a departure time

## Carvans Solution

Problem You’re given the maximum speed of N cars in the order they entered the long straight segment of the circuit. Each car prefers to move at its maximum speed. If that’s not possible because of the front car being slow, it might have to lower its speed. It still moves […]

## Ciel and Receipt Solution

ProblemTomya is a girl. She loves Chef Ciel very much. Tomya like a positive integer p, and now she wants to get a receipt of Ciel’s restaurant whose total price is exactly p. Note that the i-th menu has the price 2i-1 (1 ≤ i ≤ 12). Find the minimum number of menus whose total price is […]

## Print Binary tree in vertical order

Problem Statement Given a Binary tree, print it in vertical order from left to right. Vertical order for the above Binary tree is: Vertical order(root): 2 3 1 5 4 7 8 We could solve this problem by performing a breadth-first or level order traversal on the given tree and using […]

## Rat in the maze

Given a NxN matrix with 0s and 1s. A block with value 0 is a dead end, we cannot use this block to move ahead. While a block with value 1 can be used to travel ahead in the matrix. Now, consider mat as the starting point for the rat. We […]

## Heap Sort in C++

The Heapsort algorithm uses Heap data structure to sort an array in O(nlogn) time complexity. It starts by calling Build-Max-Heap.

## Fibonacci Numbers Solution (O(1) auxiliary space)

In mathematics, the Fibonacci series (Fn) is a sequence, such that each number in the series is the sum of the two preceding ones, starting from 0 and 1. That is, and for n > 1, Problem Statement Input a number n, print n-th Fibonacci Number.  Examples:  Input : n = […]

## Common Sorting Algorithms

A sorting algorithm is an algorithm that puts elements of a list into an order. Most frequently we’re required to sort data structures such as arrays, linked lists etc having numerical values. There’re various algorithms to sort a container or a data structure. We’ll discuss most popular or commonly used algorithms […]

## Pascal’s Triangle

In mathematics, Pascal’s triangle is a triangular array of the binomial coefficients. It can also be viewed as: each number in Pascal’s triangle is the sum of the two numbers directly above it as shown: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 […]