Comment: Flipkart, Online Assessment | E-Commerce Company | Online Video streaming platf

Comment · Posted Aug 2023

Approach problem 3: use dfs or dsu to know which cells belong to each group, let's say group 1 and group 2. Then do a bfs once from all cells of group1 and then from all cells of group 2 seprately and store them in shortest1 and shortest2,the answer would be min(shortest1+shortest2) for all cells which neither belong to group 1 nor group2.

The full answer & interview discussion are available to premium members.

Log in Create a free account