Converging Maze: Nearest meeting cell
You are given a maze with N cells. Each cell may have multiple entry points but not more than one exit
(ie. entry/exit points are unidirectional doors like valves).
The cells are named with an integer value from 0 to N-1.
You have to find:
Nearest meeting cell:
Given any two cells - C1, C2, find the closest cell Cm that can be reached from both C1 and C2.
You are given a function Solution containing arr[N], src, desc as inputs.
Complete the code in the function and return the answer from it.
Input Format
T, denoting the number of testcases, followed by 3T lines, as each testcase will contain 3 lines.NN values of the edge[] array. edge[i] contains the cell number that can be reached from cell 'i' in one step. edge[i] is -1 if the i'th cell doesn't have an exit.-1 if there is no meeting cell from the two given cells)Output Format
For each testcase given, output a single line that denotes the nearest meeting cell (NMC)
๐ Endless thanks to the friend who generously helped!