Move all Negative Numbers to Beginning and Positive to End with Constant Extra Space

Suppose you have an array of integers. It consists of both negative and positive numbers and the problem statement asks to shift/move all the negative and positive elements to the left of the array and to the right of the array respectively without using extra space. Example  Input: arr[]={2,4,-10,13,-7,-60,52,8,-19 } …

Read moreMove all Negative Numbers to Beginning and Positive to End with Constant Extra Space

Maximum difference between first and last indexes of an element in array

Suppose, you have an array of integers. The problem “Maximum difference between first and last indexes of an element in array” asks to find out the difference between the first and last index of each number present in an array such that the difference is being maximum of all. Example …

Read moreMaximum difference between first and last indexes of an element in array

Boundary Traversal of binary tree

Problem Statement The problem “Boundary Traversal of binary tree” states that you are given a binary tree. Now you need to print the boundary view of a binary tree. Here boundary traversal means that all the nodes are shown as the boundary of the tree. The nodes are seen from …

Read moreBoundary Traversal of binary tree

How to check if two given sets are disjoint?

The problem “How to check if two given sets are disjoint?” states that suppose you are given two sets in the form of array say set1[] and set2[]. Your task is to find out whether the two sets are Disjoint Sets or not. Example inputSet1[] = {1, 15, 8, 9, …

Read moreHow to check if two given sets are disjoint?

Print Fibonacci sequence using 2 variables

Problem Statement The problem “Print Fibonacci sequence using 2 variables” states that you need to print the Fibonacci sequence but there is a limitation of using only 2 variables. Example n = 5 0 1 1 2 3 5 Explanation The output sequence has the first five elements of the …

Read morePrint Fibonacci sequence using 2 variables