Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction 
2.
Problem Statement
3.
Solution
4.
Frequently Asked Questions
4.1.
What are analytical skills? 
4.2.
Why do we do puzzles in interviews?
4.3.
What is a puzzle interview?
4.4.
What are some of the most typical puzzles posed during an interview?
4.5.
Will puzzles be asked in interviews all the time?
5.
Conclusion 
Last Updated: Mar 27, 2024

Min Elevator Trips

Interview Puzzles

Introduction 

Puzzles are good exercise for the brain. They help in enhancing the cognitive abilities of the brain helping with Problem Solving and related skills. There are numerous types of puzzles; each one having a logic inherent to itself which helps in cracking it. A good puzzle well is actually like a good mystery that we may have read about or watched on TV. It has the finest of hints which help in reaching its solution.

The following article discusses one such puzzle so let's get right to it.

Illustration Image

Problem Statement

You are at the bottom of the elevator shaft of a 100-story building.

You see 21 wires labeled 1,2,3,...,21.

The wires go up to the 50th floor where the ends are labeled A, B, C, ... U, but you don’t know how which ends on top of the floor is corresponding to which end at the bottom of the floor. 

You have a light bulb, a battery, and many small wires. 

Find the minimum number of trips required to find out the pairing between the numbers and the letters.

Note: Connecting the small wires to form a wire 21 floors long is not an option. 

Solution

Note that a connection tester consists of a battery, a light bulb, and a few short wires, and that "connected" is an equivalence relation

Leave 1 unconnected at the bottom, link 2 and 3 together, 4-6 together, 7-10 together, etc., so that we have "equivalence classes" of connection for sizes 1, 2, 3, 4, 5, and 6.

Now go to the top of the list and find out which letters are associated with nothing, one other letter, two others, and so on until you've determined the equivalence classes.

Connect the initial letters of each equivalence class (there are six) in a new equivalence class, the second from each (5 of them) in a new equivalence class, and so on. Remove the old links at the bottom and find out the new equivalence classes in the same way.

We now know what groups of n letters (for n=1 to 6) at the top correlate to what groups of n numbers at the bottom, due to the first set of classes. We now know which letters and numbers were the "first" in their original classes, which were the "second," and so on, thanks to the second set of classes.

This technique works well for any triangle number of wires, and it's simple to modify to work for all natural numbers greater than 2.

Check out this problem - 8 Queens Problem

Frequently Asked Questions

What are analytical skills? 

Analytical abilities allow you to recognize the complexity of a problem, analyze and organize it, solve it, make projections, and generate new ideas. Making accurate assessments of events and offering insight into how various components interact is what analytical thinking entails. As a result, analytical skills are highly directed toward understanding cause and effect and forecasting the implications of possible solutions.

Why do we do puzzles in interviews?

Usually, interviewers ask for puzzles to see how you go about solving a tricky problem. Most companies avoid asking it because most puzzles hinge on a single trick that a person can easily miss when he is having a bad or nervous day.

What is a puzzle interview?

Microsoft popularized the puzzle interview in the 1990s. Puzzle interviews ask the applicant to solve puzzles like "Why are manhole covers round?" or unusual problems like, "How would you weigh an airplane without a scale?".

What are some of the most typical puzzles posed during an interview?

Some of the most popular interview puzzles are:

  • Crossing the Bridge Puzzle
  • Man Fell in Well Puzzle
  • The Man in the Elevator Puzzle
  • Heaven or Hell Puzzle
  • Three Mislabeled Jars
  • Gold Bar Cut Puzzle
  • Horses on a Race Track Puzzle
  • Min elevator Trips  

Will puzzles be asked in interviews all the time?

While most interviewers do not usually ask for puzzles, they are relatively frequent, and some interviews may even include specialized puzzle-solving parts. It's always a good idea to be prepared in case something happens

Conclusion 

This article discussed Min Elevator Trips along with their solution. It requires some out-of-the-box thinking to solve min elevator trips puzzle. 

Recommended Readings:


Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Happy Learning!!

Live masterclass