Author: Aswin Ashok Tester: Mayank Pugalia Editorialist: Mayank Pugalia
In this question we were given the score card (The Score and number of fallen Wickets) of a cricket match at N
moments and we had to check whether the order of the given scores was possible or not. i.e.
whether the recordings of the score done by Teja were correct or not.
We have to take care that the score at a particular moment is never strictly less that the previous
moment and the same with the wickets, also we had to make sure Teja never read two or more
scores where the wickets fallen were equal to 10.
So after taking the input we can compare the Score at moment i with i-1 for i>1 using simple if-else conditions.
If all the given scores are in order then we print YES otherwise NO
We can do the score checking in O(N) as we only need to iterate through the score cards once.
Author’s solution can be found here.
Tester’s solution can be found here.