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

Objective: Given an array of integers, find out duplicates in it. Example: int [] a = {4, 6, 2, 1, 2, 5}; Output: Array has duplicates : 2 int a [] = {1, 6,...

Objective: Given an array of integers, find out duplicates in it. Example: int [] a = {4, 6, 2, 1, 2, 5}; Output: Array has duplicates : 2 int a [] = {1, 6,...

Objective: Given two dimensional matrix, write an algorithm to find out the snake sequence which has the maximum length. There could be many snake sequence in the matrix, you need to return the one...

Objective: Given two dimensional matrix, write an algorithm to count all possible paths from top left corner to bottom-right corner. You are allowed to move only in two directions, move right OR move down....

Objective: Given two dimensional matrix, write an algorithm to print all the diagonals of matrix. Example: Approach: We will solve this problem in two parts. first half of diagonals and second half of diagonals....

Objective: The maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array of numbers which has the largest sum. Example: int [] A = {−2, 1, −3, 4, −1, 2, 1, −5,...

What is Threaded Binary Tree?? A binary tree is threaded by making all right child pointers that would normally be null point to the inorder successor of the node (if it exists), and all left child pointers...

Objective: Given a linked list write an algorithm to swap nodes in pairs by changing links . Earlier we have seen “Swap Every Kth node in a Linked List“, where we have seen how...

Objective: Given a binary search tree (BST), convert it into greater sum tree. What is greater sum tree: Greater sum tree is a tree in which every node contains the sum of all the...

Objective: Given a linked list and a number ‘k’, write an algorithm to reverse alternate ‘k’ nodes in the linked list. This problem was asked in the Microsoft and Amazon interviews. Example: Approach: Recursion...

Objective: Given a linked list and integer ‘k’, write an algorithm to reverse the linked list in groups of size ‘k’. Example: Approach: Earlier we have seen how to reverse a linked list, solution...

Objective: Given ‘N’ windows where each window contains certain number of tickets at each window. Price of a ticket is equal to number of tickets remaining at that window. Write an algorithm to sell...

Objective: Given a binary tree, write an algorithm to convert it into its Sum tree. What is Sum tree: Sum tree of a binary tree, is a tree where each node in the converted...

Objective: Given a rope of length n meters, write an algorithm to cut the rope in such a way that product of different lengths of rope is maximum. At least one cut has to...

%d bloggers like this: