Microsoft Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

How about this?
Suppose A has to send a message to B, then A will lock the box with L(A) the "lock of A" and send it to B. B can't open it B will lock the box with L(B) and send it to. A will unlock L(A) and send it to B and then B can unlock L(B) and get the message.

- PP June 14, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Right! They can initially exchange the keys using the above approach and then sends messages.

- Anonymous June 17, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it says "both get two keys with them". so "B can't open it " is not true.

A -> B : Lock_A(message)
//now B unlocks using key of A
B -> A : Lock_A
//A needs his lock back

and vars versa for B initiating a communication.

- jesuscheung September 17, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I dont think , its the right way......
The first time they will not exchange any mesage .
The A will simply lock one latch with the lock . leave the box open.
Now when this will reach to B. B will lock the 2nd latch with the A's lock.
Left letch ----A lock --- B Lock ------right latch.
Now this system will alow any of A or B to communicate with theier own key.
If any of the lock is open ........box will be open.

- Rajul August 19, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Rajul . Can u please read ur own comment. Noone can understand wht u trying to say.

- Anonymous August 21, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A puts the message in lockA and locks it, and put key A to lockB and locks it. when B receives the box, he first uses his KeyB to open lockB to get keyA, then use keyA to open lockA to get the message. the assumption is that the latch can be locked without using keys.

- Jackie August 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

actually no..! the assumption is that as long as theres at least one lock on the box, the box cannot be opened. Its a little hard to imagine such a physical box.

Using this PP's solution above makes sense. At somepoint the the box is double locked, after which each person can open a lock. The second person to open the lock also gets the message.

- acoder September 03, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Another solution is,

If A wants to deliver message to B frequently, he should let B send a lock B to him. Then he will use lock B to lock his message and lock A in the box. B will use key B to open lock B. Then B can put his message and lock B inside the box and lock the box using lock A. So A could use key A to open the box, get the message from B and get lock B....

The postman can not open the box at anytime since the key is never being exchanged. A always use key A to open the box and B always use key B to open the box. Only if they exchange the lock at the first round.

Any comments for this?

- Anonymous November 19, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This solution does not use the two latches at all. Only one latch seems to be enough. However, one overhead travel for the postman is needed. But the later exchange of message is quite easy and fast.

- Anonymous November 19, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. A puts MesgA and KeyA into box and locks with LockA.
2. A sends box to B.
3. B receives it. Locks it with LockB. Box is now locked with both LockA and LockB.
4. B sends box to A.
5. A unlocks LockA. Box is now locked with both LockB.
6. A sends box to B.
7. B unlocks LockB. B recieves MesgA and KeyA.

Moving On B has A's key. B can share KeyB is further communication with A.

- Deepak Agarwal December 06, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Deepak, you've repeated the very first solution.
What is the point of your comment?

- Anonymous June 05, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

. A puts MesgA and KeyA into box and locks with LockA.
2. A sends box to B.
3. B receives it. Locks it with LockB. Box is now locked with both LockA and LockB.
4. B sends box to A.
5. A unlocks LockA. Box is now locked with LockB.
6. A sends box to B.
7. B unlocks LockB. B recieves MesgA and KeyA.

Moving On B has A's key. B can share KeyB is further communication with A.

- Deepak Agarwal December 06, 2008 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More