To the people who have participated in TCS mockvita 2018. If anyone has solved problem C (Height of Students) ,can you please help me by providing your idea and solution?
Maybe this is not the right place to ask but I really want to know the solution as tcs does not provide editorials. Thanks in advance
I think it can be solved by building a DAG and sorting it in topological order. My solution goes like this:(Not sure if its correct as there is no link to submit)
Suppose one of the photograph gives the following list : D,C,E,F,G,H.
Then the DAG for this is H->G->F->E->C->D.
Similarly add edges from all given photographs.
Now start topo sort by queue method. If at any instant there are more than 1 nodes of zero indegree, then we need to know the heights of those nodes.
@romok did you solved any in that practice round? I was unable to solve any. Problem B and D is all I tried but donβt know why they were giving WA, can you provide your approach for them.