Skip to content

Category Archives: Searching

Given an array arr[] consisting of N integers, the task is to count the number of distinct pairs (arr[i], arr[j]) in the array such that… Read More
Given a positive integer N, the task is to count the number of integers from the range [1, N] having exactly 5 divisors. Examples: Input:… Read More
Given two positive integers L and R, the task is to find an integer X greater than 1 such that X is co-prime with all… Read More
Given a Binary Search Tree consisting of N nodes and two positive integers L and R, the task is to find the sum of values… Read More
Given a Binary Tree consisting of N nodes having distinct values from the range [1, N], the task is to find the lowest common ancestor… Read More
Given an undirected weighted graph G consisting of N vertices and M edges, and two arrays Edges[][2] and Weight[] consisting of M edges of the… Read More
Given two graphs G1 and G2, the task is to find the union and intersection of the two given graphs, i.e. (G1 ∪ G2) and… Read More
Given a Binary Tree consisting of N nodes, the task is to find the number of paths from the root to any node X, such… Read More
Given a positive integer N, the task is to find the Nth Composite Number. Examples: Input: N = 1Output: 4 Input: N = 3 Output: 8… Read More
Given a 2D array arr[][3] consisting of information of N trains where arr[i][0] is the train number, arr[i][1] is the arrival time, and arr[i][2] is… Read More
Given an array arr[] consisting of N strings, the task is to sort the array in ascending order after modifying each string by removing all… Read More
Given a string S consisting of N lowercase alphabets and an array of pairs of characters P[][2], the task is to modify the given string… Read More
Given an array arr[] consisting of N integers, the task is to find the maximum value of (arr[i] + arr[j] + i − j) for… Read More
Given a positive integer N, the task is to find the smallest semi-prime number such that the difference between any of its two divisors is… Read More
Given a positive integer N, the task is to check if the given number N can be represented as the product of two positive perfect… Read More