# Category Archives: Data Structures

## Maximum of XOR of first and second maximum of all subarrays

Given an array arr[] of distinct elements, the task is to find the maximum of XOR value of the first and second maximum elements of… Read More »

## Find all Factors of Large Perfect Square Natural Number in O(sqrt(sqrt(N))

Given a perfect square natural number N. The task is to find all the factors of N. Examples Input: N = 100 Output: 1 2… Read More »

## Program to create Custom Vector Class in C++

The task is to implement a custom vector class similar to the STL vector with following functions: int push_back(data): adds an element(of any data_type) to… Read More »

## Count of strings possible by replacing two consecutive same character with new character

Given a string str. The task is to count the number of all different strings possible if two consecutive same characters of the string can… Read More »

## Sideways traversal of a Complete Binary Tree

Given a Complete Binary Tree, the task is to print the elements in the following pattern. Let’s consider the tree to be: The tree is… Read More »

## Encryption and Decryption of String according to given technique

Given a string S, the task is to encrypt the string and decrypt the string again to the original form. Encryption Technique: If L is… Read More »

## Check if alternate path exists from U to V with smaller individual weight in a given Graph

Given a directed weighted graph with N vertices and M edges and an edge (U, V). The task is to find whether there is an… Read More »

## Least Common Ancestor of any number of nodes in Binary Tree

Given a binary tree (not a binary search tree) and any number of Key Nodes, the task is to find the least common ancestor of… Read More »

## Minimum Spanning Tree using Priority Queue and Array List

Given a bi-directed weighted (positive) graph without self-loops, the task is to generate the minimum spanning tree of the graph. Examples: Input: N = 9,… Read More »

## Append the last M nodes to the beginning of the given linked list

Given a linked list and an integer M, the task is to append the last M nodes of the linked list to the front. Examples:… Read More »

## What is Competitive Programming and How to Prepare for It?

Programming… Competitive Programming… It teaches you how to think?. If you are a programmer you might have understood the deep meaning of these lines quoted… Read More »

## Print Bottom-Right View of a Binary Tree

Given a Binary Tree, print Bottom-Right view of it. The Bottom Right view of a Binary Tree is a set of nodes visible when the… Read More »

## Print characters and their frequencies in order of occurrence using a LinkedHashMap in Java

Given a string str containing only lowercase characters. The task is to print the characters along with their frequencies in the order of their occurrence… Read More »

## Nearest greater number by interchanging the digits

Given two integers A and B. The task is to find the nearest greater value to B by interchanging the digits of A. If no… Read More »

## Bit manipulation | Swap Endianness of a number

Prerequisite: https://www.geeksforgeeks.org/little-and-big-Endian-mystery/ Little Endian and Big Endian are ways or storing data in machines. Some machines might use Little Endian byte ordering while others might… Read More »