Top 25 Programming Puzzles and Brain Teasers

Vivek Srivastava
Techie Delight

--

Following is the list of commonly asked programming puzzles in technical interviews:

  1. Clock Angle Problem
  2. Add two numbers without using the addition operator
  3. Implement power function without using multiplication and division operators
  4. Print all numbers between 1 to N without using a semicolon
  5. Swap two numbers without using a third variable
  6. Determine the if condition to print the specific output
  7. Find the maximum and minimum value of a triplet without using a conditional statement
  8. Find numbers represented as the sum of two cubes for two different pairs
  9. Print “Hello World” with empty main function
  10. Print all numbers between 1 to N without using any loop
  11. Print a semicolon without using a semicolon anywhere in the program
  12. Multiply two numbers without using a multiplication operator or loops
  13. Find the square of a number without using the multiplication and division operator
  14. Check if a number is even or odd without using any conditional statement
  15. Set both elements of a binary array to 0 in a single line
  16. Find minimum number without using conditional statement or ternary operator
  17. Perform division of two numbers without using division operator
  18. Generate 0 and 1 with 75% and 25% probability
  19. Generate desired random numbers with equal probability
  20. Return 0, 1, and 2 with equal probability using a specified function
  21. Generate fair results from a biased coin
  22. Generate numbers from 1 to 7 with equal probability using a specified function
  23. Implement ternary operator without using conditional expressions
  24. Determine if two integers are equal without using comparison and arithmetic operators
  25. Get 0 and 1 with equal probability using a specified function

Thanks for reading.

--

--