My issue
hey i got some 0rs instead of expected output but mostly the right output and i cant find the case where i get 0
My code
#include <stdio.h>
int nb_repetitons(int x, int y[100000], int num)
{
int repetitions = 0;
for (int i = 0; i <= x; i++){
if (y[i] == num){
repetitions++;
}
}
return repetitions;
}
void solve(){
int x, y[100000];
scanf("%d", &x);
for (int i = 0; i < x; i++){
scanf("%d", &y[i]);
}
for (int i = 0; i <= x; i++){
if (nb_repetitons(x, y, y[i]) % 2 != 0){
printf("%d\n", y[i]);
return;
}
}
return;
}
int main(void) {
int t;
scanf("%d", &t);
while (t--){
solve();
}
return 0;
}
Learning course: Arrays, Strings & Sorting
Problem Link: Chef and Dolls Practice Problem in - CodeChef