Longest Common Subsequence | Finding all LCS
Given two sequences, print all the possible longest common subsequences present in them.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven two sequences, print all the possible longest common subsequences present in them.
The Longest Common Subsequence (LCS) problem is finding the longest subsequence present in given two sequences in the same order, i.e., find the 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.
An island is in the form of a square matrix, and a person is standing inside the matrix. The person can move one step in any direction (right, left, top, down) in the matrix. Calculate the probability that the person is alive after walking n steps on the island, provided that he dies if he steps outside the matrix.
Write a program to calculate the nth Fibonacci number where n is a given positive number. Fibonacci’s sequence is characterized by the fact that every number after the first two is the sum of the two preceding ones.
Dynamic programming is a method for solving a complex problem by breaking it down into a collection of simpler subproblems, solving each of those subproblems just once, and storing their solutions using a memory-based data structure (array, map, etc.).