Given N equations we have to find the number of invalid equations if a certain lower case alphabet is not available for use after Xth equation.
The solution to the question is very simple. The invalid equations will be those which will have the given letter in their RHS. So For every equation after Xth equation we need to check if it has the given letter in its RHS(Right hand side). If it has that letter we will increase the count by 1. In the end we need to print the count.
Time complexity of the above solution is O(N)
AUTHOR’S AND TESTER’S SOLUTIONS:
Feel free to comment if you have any doubt .