## Puzzle | 1000 light bulbs switched on/off by 1000 persons passing by

There are 1000 light bulbs and 1000 persons. All light bulbs are initially off. Person 1 goes flipping light bulb 1, 2, 3, 4, …… Read More »

## Sum of the products of all possible Subsets

Given an array of n non-negative integers. The task is to find the sum of the product of elements of all the possible subsets. It… Read More »

## Print all non-increasing sequences of sum equal to a given number x

Given a number x, print all possible non-increasing sequences with sum equals to x. Examples: Input: x = 3 Output: 1 1 1 2 1… Read More »

## Print all possible paths from top left to bottom right of a mXn matrix

The problem is to print all the possible paths from top left to bottom right of a mXn matrix with the constraints that from each… Read More »

## Generate all unique partitions of an integer

Given a positive integer n, generate all possible unique ways to represent n as sum of positive integers. Examples: Input: n = 2 Output: 2… Read More »

## Print all possible strings of length k that can be formed from a set of n characters

Given a set of characters and a positive integer k, print all possible strings of length k that can be formed from the given set.… Read More »

## Efficient program to print all prime factors of a given number

Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12, then output… Read More »