# Category Archives: Algorithms

Given an array of integers, find all combination of four elements in the array whose sum is equal to a given value X. For example, ifâ€¦ Read More
Given two signed integers, write a function that returns true if the signs of given integers are different, otherwise false. For example, the function shouldâ€¦ Read More
You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) canâ€¦ Read More
Given a sequence of words, and a limit on the number of characters that can be put in one line (line width). Put line breaksâ€¦ Read More
Given a function foo() that returns integers from 1 to 5 with equal probability, write a function that returns integers from 1 to 7 withâ€¦ Read More
Deterministic Finite Automaton (DFA) can be used to check whether a number “num” is divisible by “k” or not. If the number is not divisible,â€¦ Read More
Write a function that calculates the day of the week for any particular date in the past or future. A typical application is to calculateâ€¦ Read More
Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number.  Example: â€¦ Read More
Given an unsorted array and a number n, find if there exists a pair of elements in the array whose difference is n. Examples:  Input: arr[]â€¦ Read More
A magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n numbers in allâ€¦ Read More
Given a number n, write a function that returns count of numbers from 1 to n that don’t contain digit 3 in their decimal representation. Examples:  â€¦ Read More
Given three corner points of a triangle, and one more point P. Write a function to check whether P lies within the triangle or not.â€¦ Read More
Write a program to find sum of positive integers without using any operator. Only use of printf() is allowed. No other library function can beâ€¦ Read More
Given a partially filled 9×9 2D array ‘grid[9][9]’, the goal is to assign digits (from 1 to 9) to the empty cells so that everyâ€¦ Read More
The partition problem is to determine whether a given set can be partitioned into two subsets such that the sum of elements in both subsetsâ€¦ Read More