# Category Archives: Mathematical

## Count of all subsequences having adjacent elements with different parity

Given an array arr[] of size N, the task is to find the number of non-empty subsequences from the given array such that no two… Read More »

## Count of submatrix with sum X in a given Matrix

Given a matrix of size N x M and an integer X, the task is to find the number of sub-squares in the matrix with… Read More »

## Rearrange an array such that product of every two consecutive elements is a multiple of 4

Given an array arr[] of size N, the task is to rearrange the array elements such that for every index i(1 <= i <= N… Read More »

## Sum of Hamming difference of consecutive numbers from 0 to N | Set 2

Given a number N, the task is to find the sum of Hamming difference of consecutive numbers from 0 to N. Hamming Distance between two… Read More »

## Square root of a number by Repeated Subtraction method

Given an integer N, the task is to find its perfect square root by repeated subtraction only. Examples: Input: N = 25 Output: 5 Input:… Read More »

## Check if N can be obtained by repetitive addition or subtraction of two given numbers

Given three positive integers N, A, and B, the task is to check if it is possible to obtain N by adding or subtracting A… Read More »

## Maximize count of distinct elements possible in an Array from the given operation

Given an array A[] of size N, the task is to maximize the count of distinct elements in the array by inserting the absolute differences… Read More »

## First number to leave an odd remainder after repetitive division by 2

Given two integers A and B, the task is to print the integer among the two, which will be converted to an odd integer by… Read More »

## Find Nth number in a sequence which is not a multiple of a given number

Given four integers A, N, L and R, the task is to find the N th number in a sequence of consecutive integers from L… Read More »

## Split array into K subsets to maximize their sum of maximums and minimums

Given an integer K and an array A[ ] whose length is multiple of K, the task is to split the elements of the given… Read More »

## Count of ways to generate a Matrix with product of each row and column as 1 or -1

Given two integers N and M, the task is to find the numbers of ways to form a matrix of size N * M consisting… Read More »

## Find largest factor of N such that N/F is less than K

Given two numbers N and K, the task is to find the minimum value X such that N < X*K. Examples: Input: N = 8,… Read More »

## Count of N-digit numbers with absolute difference of adjacent digits not exceeding K

Given two integers N and K, the task is to find the count of N-digit numbers such that the absolute difference of adjacent digits in… Read More »

## Select K elements from an array whose maximum value is minimized

Given an array arr[] having N integers and an integer K, the task is to select K elements from the given array such that sum… Read More »

## Cost of creating smallest subsequence with sum of difference between adjacent elements maximum

Given two array of N integers arr[] and costArray[], representing removal cost associated with each element. The task is to find the subsequence from the… Read More »