Top 25 Programming Puzzles and Brain Teasers
Published in
2 min readSep 12, 2018
Following is the list of commonly asked programming puzzles in technical interviews:
- Clock Angle Problem
- Add two numbers without using the addition operator
- Implement power function without using multiplication and division operators
- Print all numbers between 1 to N without using a semicolon
- Swap two numbers without using a third variable
- Determine the if condition to print the specific output
- Find the maximum and minimum value of a triplet without using a conditional statement
- Find numbers represented as the sum of two cubes for two different pairs
- Print “Hello World” with empty main function
- Print all numbers between 1 to N without using any loop
- Print a semicolon without using a semicolon anywhere in the program
- Multiply two numbers without using a multiplication operator or loops
- Find the square of a number without using the multiplication and division operator
- Check if a number is even or odd without using any conditional statement
- Set both elements of a binary array to 0 in a single line
- Find minimum number without using conditional statement or ternary operator
- Perform division of two numbers without using division operator
- Generate 0 and 1 with 75% and 25% probability
- Generate desired random numbers with equal probability
- Return 0, 1, and 2 with equal probability using a specified function
- Generate fair results from a biased coin
- Generate numbers from 1 to 7 with equal probability using a specified function
- Implement ternary operator without using conditional expressions
- Determine if two integers are equal without using comparison and arithmetic operators
- Get 0 and 1 with equal probability using a specified function
Thanks for reading.