Longest Common Increasing Subsequence (LCS + LIS)

Prerequisites : LCS, LIS Given two arrays, find length of the longest common increasing subsequence [LCIS] and print one of such sequences (multiple sequences may… Read More »

Find largest subtree having identical left and right subtrees

Given a binary tree, find the largest subtree having identical left and right subtree. Expected complexity is O(n). For example, Input: 50 / \ 10… Read More »

Arrays class in Java

The Arrays class in java.util package is a part of the Java Collection Framework. This class provides static methods to dynamically create and access Java… Read More »

Puzzle 71 | Correct Number to save life

Gabbar and his Sambha are fond of playing number games. But as usual, if Sambha loses the game, he dies. Gabbar and Sambha take their turn to call out a number between 1 to n. They follow the following rules while playing the game: Anyone of them can start the game by calling a number between 1 to 10. The person who’s chance in next, should must call a number by increasing the last number by 1 to 10,  both inclusive. Whosoever, from Gabbar and Sambha calls out “101” first wins. Sambha tries to win this game, as it’s the run… Read More »

Find paths from corner cell to middle cell in maze

Given a square maze containing positive numbers, find all paths from a corner cell (any of the extreme four corners) to the middle cell. We… Read More »

A* Search Algorithm

Motivation To approximate the shortest path in real-life situations, like- in maps, games where there can be many hindrances. We can consider a 2D Grid… Read More »

Number of ways to calculate a target number using only array elements

Given an integer array, find number of ways to calculate a target number using only array elements and addition or subtraction operator. Example: Input: arr[]… Read More »

Clone() method in Java

Object cloning refers to creation of exact copy of an object. It creates a new instance of the class of current object and initializes all… Read More »

Puzzle 70 | Tom and Jerry

Once upon a time Tom and Jerry thought of having a race on a circular track. The diameter of the track was 200 yards. They… Read More »

Adobe Interview Experience | Set 38 (4.6 Years Experienced)

Round 1: Q1. Implement memcpy function. How do you make compiler to give warning if user passes nomberOfBytes less then equal to zero. Q2. Write… Read More »

C program to simulate Nondeterministic Finite Automata (NFA)

Background An NFA is typically described using a directed graph. Each edge and vertex is labeled either 0 or 1 representing possible transitions. Vertices represent… Read More »

Check if two nodes are on same path in a tree

Given a tree (not necessarily a binary tree) and a number of queries such that every query takes two nodes of tree as parameters. For… Read More »

Linear Diophantine Equations

A Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integral solutions are required. An Integral solution is… Read More »

Scope of Variables In Java

Scope of a variable is the part of the program where the variable is accessible. Like C/C++, in Java, all identifiers are lexically (or statically)… Read More »

Generate all binary strings from given pattern

Given a string containing of ‘0’, ‘1’ and ‘?’ wildcard characters, generate all binary strings that can be formed by replacing each wildcard character by… Read More »