The longest common subsequence (LCS) problem is the problem of finding the longest subsequence that is present in given two sequences in the same order. i.e. find a longest sequence which can be obtained from the first original sequence by deleting some items, and from the second original sequence by deleting other items.
Huffman Coding (also known as Huffman Encoding) is a algorithm for doing data compression and it forms the basic idea behind file compression. This post talks about fixed length and variable length encoding, uniquely decodable codes, prefix rules and construction of Huffman Tree.
A Treap Data Structure is basically a combination of a binary search tree and a heap. Binary Search Trees – Deletions and additions of nodes can make the tree unbalanced (heavier on sides, therefore, the property we value about BSTs, the ability to distribute data by equal divisions, goes out of whack). Therefore we …
Wildcard Pattern Matching: Given a string and a pattern containing wildcard characters i.e. ‘*’ and ‘?’, where ‘?’ can match to any single character in input string and ‘*’ can match to any number of characters including zero characters, design an efficient algorithm to find if the pattern matches with the complete input string or …
Trie is a tree-based data structure used for efficient retrieval of a key in a huge set of strings. In this post, we will implement Trie data structure in Java.
The longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence’s elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique.
In this post, we will discuss about std::prev_permutation which can be used to find the lexicographically smaller permutations of a string.
Given a set of intervals, print all non-overlapping intervals after merging overlapping intervals.
Given an circular array of integers, find subarray in it which has the largest sum.
Given an array of integers, find contiguous subarray within it which has the largest sum.
In this post, we will discuss about std::next_permutation which can be used to find the lexicographically greater permutations of a string.
Given an array of integers containing duplicates, return the majority element in an array if present. A majority element appears more than n/2 times where n is the size of the array.