Tagged: Intermediate

11

Dynamic Programming – Longest Common Subsequence

Objective: Given two string sequences, write an algorithm to find the length of longest subsequence present in both of them. These kind of dynamic programming questions are very famous in the interviews like Amazon,...

4

Dynamic Programming – Minimum Cost Path Problem

Objective: Given a 2D-matrix where each cell has a cost to travel. You have to write an algorithm to find a path from left-top corner to bottom-right corner with minimum travel cost. You can...

1

All N Length Strings from Given String of Length K

Objective: Print All N Length Strings from Given String of Length K where characters can appear multiple time. Example: String k = “ALGO” N=2 Result: AA LA GA OA AL LL GL OL AG...

0

Generate Well Ordered Passwords of a Given Length K

Objective: Generate Well Ordered Passwords of a Given Length K. Well ordered means that digits should be in increasing order in every generated password. Example: K = 7 1234567 1234568 1234569 1234578 1234579 1234589...

2

Dynamic Programming – Maximum size square sub-matrix with all 1s

Objective: Given a matrix of 0’s and 1’s (binary matrix). Find out Maximum size square sub-matrix with all 1’s. Example: Approach: Base Cases: If only one row is given then cells with 1’s will...

6

Dynamic Programming – Longest Increasing Subsequence

Objective: The longest Increasing Subsequence (LIS) problem is to find the length of the longest subsequence in a given array such that all elements of the subsequence are sorted in increasing order. OR Given...

12

Dynamic Programming – Minimum Coin Change Problem

Objective: Given a amount ‘A’ and n coins,   v1<v2<v3<………..<vn . Write a program to find out minimum numbers of coins required to make the change for the amount ‘A’. Example: Amount: 5 Coins []...

2

Print All Paths From Root In a Binary Tree Whose Sum is Equal to a Given Number

Objective: – Given a binary tree and X, write an algorithm to Print all the paths starting from root so that sum of all the nodes in path equals to a given number. Example:

5

Find the Deepest Node in a Binary Tree.

Objective: – Given a binary tree, write an algorithm to Find the deepest node in it. Approach: Take two global variable as “deepestlevel” and “value“. starting with level=0, Do the inorder traversal and whenever...

%d bloggers like this: