# Category Archives: Searching

## Check if an array is sorted and rotated using Binary Search

Pre-requisite: Check if an array is sorted and rotated using Linear Search Given an array arr[] of N distinct integers, the task is to check… Read More »

## NFA to accept strings that has atleast one character occurring in a multiple of 3

Prerequisites: Finite Automata Given a string str consisting of characters a, b and c, check if the number of occurances of any character in the… Read More »

## Count positions such that all elements before it are greater

Given an array A[], the task is to find the number of positions i in the array such that all elements before A[i] are greater… Read More »

## Count of Subsets of a given Set with element X present in it

Given an array arr[] of N unique positive integers and an element X, the tasks is to count the total possible number of subsets of… Read More »

## Length of Longest Subarray with same elements in atmost K increments

Given an integer array arr and a number K, the task is to find the length of longest subarray such that all the elements in… Read More »

## Maximum length L such that the sum of all subarrays of length L is less than K

Given an array of length N and an integer K. The task is to find the maximum length L such that all the subarrays of… Read More »

## Smallest number greater than n that can be represented as a sum of distinct power of k

Given a number n and a value k, the task is to find the smallest m(m>=n), such that m can be represented as a sum… Read More »

## Count of numbers from range [L, R] that end with any of the given digits

Given a range [L, R], the task is to find the count of numbers from the range whose last digit is either 2, 3 or… Read More »

## Minimum K such that sum of array elements after division by K does not exceed S

Given an array arr[] of N elements and an integer S. The task is to find the minimum number K such that the sum of… Read More »

## Longest substring with K unique characters using Binary Search

Given a string str and an integer K, the task is to print the length of the longest possible substring that has exactly K unique… Read More »

## Value to be subtracted from array elements to make sum of all elements equals K

Given an integer K and an array height[] where height[i] denotes the height of the ith tree in a forest. The task is to make… Read More »

## Check if given string contains all the digits

Given a string str consisting of alphanumeric characters, the task is to check whether the string contains all the digits from 1 to 9. Examples:… Read More »

## Check if a symmetric plus is possible from the elements of the given array

Given an array arr[] of N elements, the task is to check whether a symmetric plus is possible with the elements of the given array.… Read More »

## Queries for elements greater than K in the given index range using Segment Tree

Given an array arr[] of N elements and a number of queries where each query will contain three integers L, R and K. For each… Read More »

## Calculate the Sum of GCD over all subarrays

Given an array of integers, the task is to calculate the sum of GCD of all the subarrays of an array. GCD of an array… Read More »