We have there arrays, Array A with input string, Array oldc which tells which characters of the input string needs to be replaced and Array newc tells with which characters we will replace the characters of A.
Ex: A=abcde, oldc = abc and newc = dab.
Every occurance of a in A need to be replaced by d, each b will be replaced with a, each c with b, then we will get our output .
Input A=abcde, expected output A = dabde
But because there is a flaw(program not designed well) in the program, because of which when we give a input, we are not getting expected output.
Lets see where the program fails to give expected output.
Lets take 3rd test case and A = bcdea
oldc = bca, newc = cda; the expected output is A=cddec; lets see what program gives as output
i=0, j=0 ==> a[0] == oldc[0] ==> a[0] = new[0] = c ;
After this iteration updated string A=ccdea and now A[0] = c;
i=0, j=1 ==> a[0] == oldc[1] ==> a[0] = new[1] = d
After this iteration updated string A=dcdea and now A[0] = d;
If you notice, A[0] first changed to c and again to d which is the flaw here, we are expected to change only once but change is happening twice.
This is because when first character is changed to something , that something is again present in oldc after current index which is making it to change again when we reach that index, which we don’t want to happen.
This will happen in 3,4 test cases and not in 1,2 test cases, that is why 3,4 test cases detect the flaw.
see this image for why 3,4 can detect the flaw.
image credits: amarVashishth
In 3,4 test cases the changed character is again present in oldc array after current index, which makes the characted to change again.
Answer:B) only two