Airbnb | Phone | Alien Dictionary & Boxes and Candies
Anonymous User
5246

First Interview
https://leetcode.com/problems/alien-dictionary (premium)
I did not see this question before, knew it is popular interview question. Should have gone through it once.

Second Interview:
I give you a box

  1. A box can either be locked or unlocked
  2. Inside the box you will find: # candy, # inner boxes, # keys
  3. Keys correspond to specific boxes
  • What is maximum number of candy you can retrieve?

  • EXAMPLE

  • I gave you box A

  • A = { unlocked, 7 candy, boxes=[B, C], keys=[] }

  • B = { locked, 5 candy, boxes=[D], keys=[] }

  • C = { unlocked, 4 candy, boxes=[], keys=[B] }

  • D = { locked, 100 candy, boxes=[], keys=[] }

  • I give you box A, what is the maximum # of candy you can retrieve? 16

  • HINT 1: Think, what are the conditions in which a box is "ready" to be opened?

  1. If you discover a new box and it is already unlocked
  2. I have previously found key X, and now I find locked box X
  3. I find key Y, and have already seen locked box Y

Did pretty bad in both the interviews. So sad that they expect intern to be as smart as their current software engineers. But, it is good that I realised I am dumb after this interview lol. Solution for 2nd question is appriciated.

Comments (15)