CR1 - Editorial

Practice

Author: Mann Mehta

Tester: Vatsal Parmar

Editorialist: Jaymeet Mehta

DIFFICULTY

Cakewalk

PREREQUISITES

Observation

PROBLEM

There are N students, hence one of them having a solution of problems now he pass it to other student and that student again pass it to another. Hence they form a chain of delivery of solution.
Now your task is to find total number of student got the solution and that student who recieve the solution in the last.

EXPLANATION

Let suppose initially student X as a solution then he give to Y, then Y give that solution to Z and so on...
As we see the queries always begin with the initial student as he is only one knowing the soltuion.

Here we just need to take track of students recieving the solution, if a fresh student got the solution in delivery process then nowonwards he need to consider in one of the cheated student.

In the end only one student having that solution, that will be taken care by keeping track of receiving student’s, student who receive the solution in the end its our required answer.

This is so trivial question. If you still not understand then see the solution for better understanding.

TIME COMPLEXITY

Time Complexity is O(N) per test case.

SOLUTIONS

Author Solution