# Category Archives: Pattern Searching

## Check if a string can be split into substrings starting with N followed by N characters

Given a string str, the task is to check if it can be split into substrings such that each substring starts with a numeric value… Read More »

## Largest number made up of X and Y with count of X divisible by Y and of Y by X

Given three integers X, Y and N, the task is to find the largest number possible of length N consisting only of X and Y… Read More »

## Sum of all divisors from 1 to N | Set 3

Given a positive integer N, the task is to find the sum of divisors of all the numbers from 1 to N. Examples: Input: N… Read More »

## Represent K as sum of N-bonacci numbers

Given two numbers K and N. The task is to represent the given number K as a sum of several N-bonacci numbers. Examples: Input: K… Read More »

## Count all indices of cyclic regular parenthesis

Given a string S of length N, consisting of only opening ‘(‘ and closing ‘)‘ parenthesis. The task is to find all indices ‘K‘ such… Read More »

## Count of occurrences of each prefix in a string using modified KMP algorithm

Given a string S of size N, the task is to count the occurrences of all the prefixes of the given string S. Examples: Input:… Read More »

## Sum of consecutive bit differences of first N non-negative integers

Given a positive integer N, the task is to find out the sum of all consecutive bit differences from 0 to N. Note: If the bit… Read More »

## Divide N into K parts in the form (X, 2X, … , KX) for some value of X

Given a positive integer N and K, the task is to divide N into K parts such that the first part has a value X,… Read More »

## Count of ways to split given string into two non-empty palindromes

Given a string S, the task is to find the number of ways to split the given string S into two non-empty palindromic strings. Examples:… Read More »

## Final direction after visiting every cell of Matrix starting from (0, 0)

Given a 2D grid of size N x M. The task is to find the final direction after visiting every cell under given conditions. You… Read More »

## Smallest number whose square has N digits

Given a number N, the task is to find the smallest number whose square has N digits. Examples: Input: N = 2 Output: 4 Explanation:… Read More »

## Bitonic string

Given a string str, the task is to check if that string is a Bitonic String or not. If string str is Bitonic String then… Read More »

## Find pair with maximum GCD for integers in range 2 to N

Given a number N, the task is to find a pair of integers in the range [2, N] with maximum GCD. Examples: Input: N =… Read More »

## Find initial sequence that produces a given Array by cyclic increments upto index P

Given an array arr[] consisting of N elements and an integer P, the task is to find the initial array from which given arr[] is… Read More »

## Generate a unique Array of length N with sum of all subarrays divisible by N

Given an integer N, the task is to make an array of unique elements of length N such that all subarrays sum modulo N equals… Read More »