Given an array, write a program to generate a random permutation of array elements. This question is also asked as “shuffle a deck of cards”… Read More
Category Archives: Mathematical
Given a string, print all permutations of it in sorted order. For example, if the input string is “ABC”, then output should be “ABC, ACB,… Read More
Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. The expected… Read More
Given a number N, the task is to check if it is divisible by 7 or not.Note: You are not allowed to use the modulo… Read More
You are given a function foo() that represents a biased coin. When foo() is called, it returns 0 with 60% probability, and 1 with 40%… Read More
Given a number, find the next smallest palindrome larger than this number. For example, if the input number is “2 3 5 4 5”, the… 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
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
There are N people standing in a circle waiting to be executed. The counting out begins at some point in the circle and proceeds around… Read More