Category: NetApp

Find duplicates in an given array in O(n) time and O(1) extra space.

Objec­tive: Given an array of inte­gers, find out dupli­cates in it. Exam­ple: int [] a = {4, 6, 2, 1, 2, 5}; Out­put: Array has dupli­cates : 2 int a [] = {1, 6, 5,…

Dynamic Programming — Highway Billboard Problem

Objec­tive:  Sup­pose you’re man­ag­ing con­struc­tion of bill­boards on the Rocky & Bull­win­kle Memo­r­ial High­way, a heav­ily trav­eled stretch of road that runs west-east for M miles. The pos­si­ble sites for bill­boards are given by…

Dynamic Programming — Longest Palindromic Subsequence

Objec­tive: Given a string, find a longest palin­dromic sub­se­quence in it. What is Longest Palin­dromic Sub­se­quence: A longest palin­dromic sub­se­quence is a sequence that appears in the same rel­a­tive order, but not nec­es­sar­ily contiguous(not substring)…

Dynamic Programming — Maximum Product Cutting Problem.

Objec­tive: Given a rope of length n meters, write an algo­rithm to cut the rope in such a way that prod­uct of dif­fer­ent lengths of rope is max­i­mum. At least one cut has to…

Generate Well Ordered Passwords of a Given Length K

Objec­tive: Gen­er­ate Well Ordered Pass­words of a Given Length K. Well ordered means that dig­its should be in increas­ing order in every gen­er­ated pass­word. Exam­ple: K = 7 1234567 1234568 1234569 1234578 1234579 1234589…

The Word Break Problem

Objec­tive : Given an string and a dic­tio­nary of words, find out if the input string can be bro­ken into a space-separated sequence of one or more dic­tio­nary words. Exam­ple: dic­tio­nary = [“I” , “have”,…

Backtracking — Knight’s Tour Problem

Objec­tive : A knight’s tour is a sequence of moves of a knight on a chess­board such that the knight vis­its every square only once. If the knight ends on a square that is…

Dynamic Programming — Minimum Coin Change Problem

Objec­tive: Given a amount ‘A’ and n coins,   v1<v2<v3<.….……<vn . Write a pro­gram to find out min­i­mum num­bers of coins required to make the change for the amount ‘A’. Exam­ple: Amount: 5 Coins []…

Objec­tive: Reverse The Dou­bly Linked List. Example:

Print All The Nodes Which are X distance from the Given Node

Objec­tive: — Given Binary Tree, Print All The Nodes Which are X dis­tance from the Given Node. Exam­ple : Appraoch: Quite Tricky solu­tion, i will explain using the exam­ple given in the picture.

Print the Vertical Sum in binary Tree .

Objec­tive: — Given a binary tree, print it in ver­ti­cal order sum What is Ver­ti­cal Order Sum as you can see in the exam­ple above, [4],[2], [12],[3],[7] are the ver­ti­cal order sum of the given binary…

Print the Binary Tree in Vertical Order Path.

Objec­tive: — Given a binary tree, print it in ver­ti­cal order path. What is Ver­ti­cal Order as you can see in the exam­ple above, [4],[2], [1,5,6],[3],[7] are the ver­i­cal order of the given binary tree. Approach:

Find Intersection Point in Two Linked List

Objec­tive: Given Two linked list, check whether both list inter­sect each other, if yes then find the start­ing node of the inter­sec­tion. Inter­sec­tion point means end of one linked list is linked with some…