My issue
Can someone please explain the reasoning behind the explanation of the test cases in a bit more detail?
My code()
#include <stdio.h>
#include <string.h>
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int N;
scanf("%d", &N);
char S[N+1], R[N+1];
scanf("%s %s", S, R);
}
}
Learning course: Solve Programming problems using C
Problem Link: CodeChef: Practical coding for everyone
@nitheesha39
The question states that initially the bulb is on .
and u have initial state of the buttons and final state of the buttons
if the state of ith button changes then the bulb will toggle means if its in then it become off else its become on.
like example
000
111
for i=0 button changes its form then bulb will become off cozz initially it was on.
for i=1 again change means bulb will get on.
for i=2 again change means bulb will get off.
so answer would be 0; which is off
@dpcoder_007
Is it enough if I count no.of 1’s in the second string? If it is an even number then output is 1 else 0.
@nitheesha39
No its not bcozz suppose
0 1 0
1 0 1
at initially 0 1 0 gives u on
now at each changes it will change its state
so if u will count only one then it will give u wrong ans.
so u have to count the changes only if changes if even then bulb will be on else it will be off.
1 Like
@dpcoder_007
Understood. Thank you.