A slot that has been counted as a perfect hit can never count as a pseudo-hit.
Original String = “RGYB” and Guess String = “YGRR”.
The second slot of both the guess and original matches, hence it’s a perfect hit. The guess string contains yellow, which is also present in the original string but not at the same slot as the guess slot. Hence it’s a pseudo hit. The guess string also contains two red slots, but the original string contains only one red which is also not at the same slot as the guess string; hence it is also a pseudo hit. Therefore total points will be 2+1+1= 4.
The first line of the input contains an integer T denoting the number of test cases.
The first line of each test contains a string ‘original’, representing the original color of four slots.
The second line of each test case contains a string, ‘guess,’ representing the guessed color of four slots.
For every test case, print the total number of points that you have scored.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 5
length(original) = length(guess) = 4
Time limit: 1 sec
We will check for each slot, whether it’s a perfect hit or a pseudo hit.
Below is the detailed algorithm:
Return 'POINTS'.
We will create a frequency array that will store how many times each colour exists in the original string, excluding those times when there was a perfect hit.
Below is the detailed algorithm:
Missing Number
Longest Subarray With Zero Sum
Merge Two Sorted Arrays Without Extra Space
Ninja And The Strictly Increasing Array
Negative To The End