Close

Longest common subsequence problem

This is a famous computer science problem with various applications in tools such as file diff, bio informatics etc. For more information read this on wiki. Given a set of strings, how do we find the longest common sub-sequence(LCS) among them? For example, LCS{“ATDACG”,”CTDACGA”} is  “TAG”. In this post, we will look at the algorithm…

Finding equal sum index

Given an array of numbers, find an index such that the sum of numbers to the left is equal to the sum of elements to it’s right. If there are no elements to the left or right, the sum is considered to be zero.This problem is from Hackerrank. Click here to solve this problem on…

Forming the nth binary sequence

A binary sequence contains 0 and 1 only S.No  Binary sequence——————–1     02     13     004     015     10…Given a number k, we have to design an algorithm to print kth binary sequence. Initial approach (not efficient): Starting from the sequence 0, this algorithm iterates k times. To get the next sequence, in each iteration we do the following. check the last…