Total numbers with no repeated digits in a range

Given a range find total such numbers in the given range such that they have no repeated digits. For example: 12 has no repeated digit.… Read More »

K maximum sums of overlapping contiguous sub-arrays

Given an Array of Integers and an Integer value k, find out k sub-arrays(may be overlapping) which have k maximum sums. Examples: Input : arr… Read More »

Maximum subarray sum in O(n) using prefix sum

Given an Array of Positive and Negative Integers, find out the Maximum Subarray Sum in that Array. Examples: Input1 : arr = {-2, -3, 4,… Read More »

Optimal partition of an array into four parts

Given an array of n non-negative integers. Choose three indices i.e. (0 <= index_1 <= index_ 2<= index_3 <= n) from the array to make… Read More »

Number of substrings with odd decimal value in a binary string

Given a binary string containing only 0’s and 1’s. Write a program to find number of sub-strings of this string whose decimal representation is odd.… Read More »

Count subsequence of length three in a given string

Given a string of length n and a subsequence of length 3. Find the total number of occurrences of the subsequence in this string. Examples… Read More »

Maximum array sum with prefix and suffix multiplications with -1 allowed

Given N elements (both positive and negative). Find the maximum sum, provided that the first operation is to take some prefix of the sequence and… Read More »

Longest subsequence of the form 0*1*0* in a binary string

Given a binary string, find the longest subsequence of the form (0)*(1)*(0)* in it. Basically we need to divide the string into 3 non overlapping… Read More »

Count Primes in Ranges

Given a range [L, R], we need to find the count of total numbers of prime numbers in the the range [L, R] where 0… Read More »

Mean of range in array

Given an array of n integers. You are given q queries. Write a program to print floor value of mean in range l to r… Read More »

Print modified array after executing the commands of addition and subtraction

Given an array of size ‘n’ and a given set of commands of size ‘m’. Every command consist of four integers q, l, r, k.… Read More »

Count of substrings of a binary string containing K ones

Given a binary string of length N and an integer K, we need to find out how many substrings of this string are exist which… Read More »

Find an element in array such that sum of left array is equal to sum of right array

Given, an array of size n. Find an element which divides the array in two sub-arrays with equal sum. Examples: Input : 1 4 2… Read More »

Minimum absolute difference of XOR values of two subarrays

Given an array containing n numbers. The problem is to split the array into two subarrays such that the absolute difference of the xor values… Read More »

Count subarrays with equal number of occurrences of two given elements

Given an array and two integers say, x and y, find the number of subarrays in which the number of occurrences of x is equal… Read More »