You are climbing a staircase. It has n steps upto the top. Each time you can either climb 1 step or 2 steps. You’ve to find the number of ways to climb the stair.
Given two non-negative integers a and b, you’ve to find the Greatest Common Divisor (GCD) or Highest Common Factor (HCF) of the two numbers. In other words, find the largest number that divides them both. The Euclidean algorithm is one of the oldest numerical algorithms to compute the greatest common divisor (gcd) of two positive integers.
In the last post we discussed about C++ Standard Template Library (STL) Linked List. In this post we will learn about STL Priority queue and using it as Max/Min Heap. A priority queue is a data structure for maintaining a set of elements having an associated value.
The C++ Standard Template Library (STL) is a powerful library of C++ template classes that provide general-purpose classes and functions. It has implementations of many popular and commonly used algorithms and data structures like vectors, linked-lists etc.
Huffman codes are a widely used technique for compressing data. Huffman codes is a greedy algorithm to build up an optimal way of representing each character as a binary string. Suppose we have a 10,000 character data file that we wish to store. And we observe a character ‘a’ occurs very frequently.
Array rotation is a problem of changing the order of the elements of the array. Decreasing the index of the element by one and changing the index of the first element to n-1.
In the previous post, we discussed about finding the total number of continuous subarrays of a given array (of non-negative numbers) whose sum equals to k. In this post we’ll include negative numbers in the given array arr.