had FB screening round.
15 mins behavioural
pivot to coding
q1. ocean view
q2. return path from entrance to exit in a 2d grid (having walls)
a little followup to Q2. additionally the grid ll contains locks with its keys.
overall, it went fine I think. not adding the solutions since the ques/solution should be available on leetcode.
// Ocean View
// Input: [4, 3, 2, 3, 1]
// Output: [0, 3, 4]
//
// ___
// 4 | | ___ ___
// 3 | | | | ___ | |
// 2 | | | | | | | | ___
// 1 | | | | | | | | | |
// ~~~~~ Ocean
// b0, b1, b2, b3, b4
// b4 -> b0
// [ b4, b3, b0]
// entrance -> 0 0 0 0 0 0 0
// 0 0 1 0 0 1 0
// 0 0 1 0 1 1 0
// 0 0 1 0 1 0 1
// 1 1 1 0 0 0 0 -> exit
// [0,0]->H,V -> [m,n], if pathexists -> return the path(entrance->exit)
// 0 -> empty, 1 -> wall
// solution: DFS(entrance) -> H,V 4 direction -> exit (visited inplace = 2, grid), O(mxn), O(mxn)
// dfs, x,y if(x,y) == key, keep the key in keyset (Set<Char>)
// if(x,y) == Lock and if (keyset.unlock(Lock)) // move forward
// if traversing completed for the cell, remove the key from the keyset
// reach A -> visited = 2
// reach a afterwards -> ++visited = 3
// if newvisited > visited ->