2 Technical rounds have been conducted so far. I wasnt able tp get to the optimised solution for the following problem. Can somebody suggest solution?
Question goes like..
You are given a flat file of certain relations like
1 meter -> 4 elephants
2 elephants->1 turtle
Say if he asks whats the relationship between meter and turtle, then the response will be 0.5 meter - > 1 turtle.
I suggested using a hashmap/dictionary - storing the parent child relationship and we start from' meter' until we find turle and return the relationship. Then he asked what if there are like a million entries in between and what's the optimisation or is there any other datastrcuture that would optimise it. I wasnt able to anwer completely.
Leetcoders, please help!