Euler Function: In number theory, Euler’s totient function (or Euler’s phi function), denoted as φ(n) or ϕ(n), is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to n , i.e., the numbers whose GCD (Greatest Common Divisor) with n is 1. (These integers are sometimes … Read More →

## Euclid’s Algorithm (Greatest Common Divisor) – GCD

Given two non-negative integers a and b. We need to find their greatest common divisor (GCD), ie, the largest number that divides both a and b. When it is of the numbers is zero, and the other is non-zero, their greatest common divisor, by definition, it is the second number. When both numbers are zero, … Read More →

## How Long Was He Walking

Puzzle: Every day, Jack arrives at the train station from work at 5 pm. His wife leaves home in her car to meet him there at exactly 5 pm, and drives him home. One day, Jack gets to the station an hour early, and starts walking home, until his wife meets him on the road. … Read More →

## Top 10 Logic Puzzles

So you think you are clever, right? Then here is your chance to pit your brain against some of the world’s hardest logic puzzles ever created. 1. 10 identical bottles of pills We have 10 identical bottles of identical pills (each bottle contain hundred of pills). Out of 10 bottles 9 have 1 gram of … Read More →

## Count Total Set Bits in All Numbers From 1 to N

Problem: Given a positive integer n, count the total number of set bits in binary representation of all numbers from 1 to n. Examples: Input: n = 3 Output: 4 Input: n = 6 Output: 9 Input: n = 7 Output: 12 Input: n = 8 Output: 13 Solution: The solution is to run a … Read More →

## Snapdeal Interview Questions – Set 4

Software Development Engineer In Test Interview I applied through a recruiter. The process took 1 day. I interviewed at Snapdeal (Gurgaon, Haryana). 2 Round was on developing the automation framework approaches and general java based algorithm to some complex variations to puzzle you. Q1. Find the first non repetitive element in an array. Q2. Implement … Read More →

## Shopclues Interview Questions – Set 1

Hi my name is Surender. Shopclues recently visited our campus for recruitment.I’m mentioning below there interview process and the interview questions asked. Three Rounds(1 written + 2 interviews) Round 1 (Written Test) It consisted of eleven aptitude questions which were to be solved in one hour. For software profile there were five more questions based … Read More →

## 2 Player and N Coin – Strategy Puzzle

Puzzle: There are n coins in a line. (Assume n is even). Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins. Would you rather go first or second? Does it matter? Assume … Read More →

## Find the Maximum of Two Numbers Without Using if-else

Find the maximum and minimum of two integers without branching i.e. if condition. Solution: Minimum of two numbers can be found from the following: Min(x,y) = y ^ ((x ^ y) & -(x < y)) It works because if x < y, then -(x < y) will be all ones, so r = y ^ … Read More →

## Find the Element that Appears Once

Problem: Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. Expected time complexity is O(n) and O(1) extra space. Examples: Input: arr[] = {10, 1, 10, 3, 10, 1, 1, 2, 3, 3} Output: 2 Solution: If O(1) space constraint was not … Read More →

## Check if a Singly Linked List is Palindrome

Given a singly linked list, determine if its a palindrome. Return 1 or 0 denoting if its a palindrome or not, respectively. Notes: – Expected solution is linear in time and constant in space. For example, List 1–>2–>1 is a palindrome. List 1–>2–>3 is not a palindrome. Solution: This method takes O(n) time and O(1) … Read More →

## Minimum no Of Aircraft Puzzle

Puzzle: On Bagshot Island, there is an airport. The airport is the home base of an unlimited number of identical airplanes. Each airplane has a fuel capacity to allow it to fly exactly 1/2 way around the world, along a great circle. The planes have the ability to refuel in flight without loss of speed … Read More →

## What’s going on ?