Number of subarrays have bitwise OR >= K

Given an array arr[] and an integer K, the task is to count the number of sub-arrays having bitwise OR ≥ K. Examples: Input: arr[]… Read More »

Number of connected components in a doubly linked list

Given a doubly linked list ‘L’ and an array ‘refArr’ of references to the nodes of the doubly linked list ‘L’. Array 'refArr' does not… Read More »

Generate permutation of 1 to N such that absolute difference of consecutive numbers give K distinct integers

Given two integers N and K where K < N, the task is to generate a permutation of integers from 1 to N such that… Read More »

Minimum absolute difference between N and a power of 2

Given an integer N, the task is to find the minimum absolute difference between N and a power of 2. Examples: Input: N = 4… Read More »

Decrypt a string according to given rules

Given an encrypted string str, the task is to decrypt the given string when the encryption rules are as follows: Start with the first character… Read More »

Print all subsequences of a string using ArrayList

Given a string str, the task is to print all the sub-sequences of str. A subsequence is a sequence that can be derived from another… Read More »

Represent n as the sum of exactly k powers of two | Set 2

Given two integers n and k, the task is to find whether it is possible to represent n as the sum of exactly k powers… Read More »

Pairs with same Manhattan and Euclidean distance

In a given Cartesian plane, there are N points. The task is to find the Number of Pairs of points(A, B) such that Point A… Read More »

Check if a number is perfect square without finding square root

We need to check whether a number is a perfect square or not without finding its square root. Examples: Input : n = 36 Output… Read More »

Find the sums for which an array can be divided into sub-arrays of equal sum

Given an array of integers arr[], the task is to find all the values for sum such that for a value sum[i] the array can… Read More »

Find the number in a range having maximum product of the digits

Given a range represented by two positive integers L and R. Find the number lying in the range having the maximum product of the digits.… Read More »

Count numbers in a range that are divisible by all array elements

Given N numbers and two numbers L and R., the task is to print the count of numbers in the range [L, R] which are… Read More »

Find k numbers which are powers of 2 and have sum N | Set 1

Given two numbers N and K. The task is to print K numbers which are powers of 2 and their sum is N. Print -1… Read More »

Buy minimum items without change and given coins

You have an unlimited number of 10-rupee coins and exactly one coin of r rupee and you need to buy minimum items each of cost… Read More »

Count of Numbers in a Range divisible by m and having digit d in even positions

Given a range represented by two positive integers l and r and two integers d and m. Find the count of numbers lying in the… Read More »