# Category Archives: Algorithms

## Efficient method for 2’s complement of a binary string

Given a Binary Number as string, print its 2’s complements. 2’s complement of a binary number is 1 added to the 1’s complement of the… Read More »

## Find minimum number to be divided to make a number a perfect square

Given a positive integer n. Find the minimum number which divide n to make it a perfect square. Examples: Input : n = 50 Output… Read More »

## Sublist Search (Search a linked list in another list)

Given two linked lists, the task is to check whether the first list is present in 2nd list or not. Examples: Input : list1 =… Read More »

## Check whether a point exists in circle sector or not.

We have a circle centered at origin (0, 0). As input we are given with starting angle of the circle sector and the size of… Read More »

## Sort an array when two halves are sorted

Given an integer array of which both first half and second half are sorted. Task is to merge two sorted halves of array into single… Read More »

## Choose k array elements such that difference of maximum and minimum is minimized

Given an array of n integers and a positive number k. We are allowed to take any k integers from the given array. The task… Read More »

## Unbounded Knapsack (Repetition of items allowed)

Given a knapsack weight W and a set of n items with certain value vali and weight wti, we need to calculate minimum amount that… Read More »

## Ways to write n as sum of two or more positive integers

For a given number n > 0, find the number of different ways in which n can be written as a sum of at two… Read More »

## Generate all binary strings without consecutive 1’s

Given a integer K. Task is Print All binary string of size K (Given number). Examples: Input : K = 3 Output : 000 ,… Read More »

## Program to implement Collatz Conjecture

Given a positive integer n, the task is to find whether this number reaches to 1 after performing following two operations:- If n is even,… Read More »

## GCD of two numbers formed by n repeating x and y times

Given three positive integer n, x, y. The task is to print Greatest Common Divisor of numbers formed by n repeating x times and number… Read More »

## Compare two integers without using any Comparison operator

Given two integers A & B. Task is to check if A and B are same or not without using comparison operators. Examples: Input :… Read More »

## Permute two arrays such that sum of every pair is greater or equal to K

Given two arrays of equal size n and an integer k. The task is to permute both arrays such that sum of their corresponding element… Read More »

## Count natural numbers whose factorials are divisible by x but not y

Given two numbers x and y (x <= y), find out the total number of natural numbers, say i, for which i! is divisible by… Read More »

## Count of subarrays whose maximum element is greater than k

Given an array of n elements and an integer k. The task is to find the count of subarray which has maximum element greater than… Read More »