Category Archives: Interview Questions

Finding loop in a singly linked-list

You can detect it by simply running two pointers through the list. Start the first pointer p1 on the first node and the second pointer p2 on the second node. Advance the first pointer by one every time through the loop, advance … Continue reading

Posted in Algorithms, Interview Puzzles | Tagged , , , | Leave a comment

Combinations of a String

Problem: Write an algorithm to print all possible combinations of characters in a string. Solution: Since we need to generate combinations, we can start with a single character and then continue to add a character to combinations we have seen … Continue reading

Posted in Interview Puzzles | Tagged , , , , , | 1 Comment

Gold for 7 Days of Work Puzzle

Problem Statement: You’ve got someone working for you for seven days and a gold bar to pay them. You must pay the worker for their work at the end of every day. If you are only allowed to make two … Continue reading

Posted in Interview Puzzles | Tagged , , | Leave a comment

Fastest 3 out of 25 Horses Problem

Problem Statement You have 25 horses, and you want to pick the fastest 3 horses out of those 25. Each race can have maximum of 5 horses at the same time. What is the minimum number of races required to … Continue reading

Posted in Interview Puzzles | Tagged , , | Leave a comment

100 floors with 2 eggs puzzle

Problem Statement: There is a building of 100 floors  If an egg drops from the Nth floor or above it will break. If it’s dropped from any floor below, it will not break. You’re given 2 eggs. Give an Algorithm to … Continue reading

Posted in Interview Puzzles | Tagged , , , | 1 Comment

The water jug problem

We have three water jugs, and each can hold 3oz., 5oz., and 8oz. of water, respectively. Without the possibility of water spilling when poured from one jug to another, and given that the jugs have no calibration, how do we … Continue reading

Posted in Interview Puzzles, Interview Questions | Tagged , , | 1 Comment

Interview questions — Serializable

Suppose I have 2 classes1) Person having person name = “Yogesh”;2) User having username = “User” extends Person and implements Serializable. What will be the values printed if I serialize and deserialize the User object? I guessed it wrongly and … Continue reading

Posted in Interview Questions | Leave a comment