There is probably a simple answer but while practicing some questions on hacker rank the "aScore" isn't saying at a certain value, the first value in a[i]
is greater than b[i]
. I've been trying to debug the code but I can't print what I want to the console on hacker rank, it's forced to come out to the answer's output somehow.
public static List<int> compareTriplets(List<int> a, List<int> b)
{
int aScore=0;
for(int i=0; i ==(a.Count-1);i )
if (a[i]>b[i]){
aScore ;
}
return new List<int>(){aScore,1} ;
}
}
CodePudding user response:
for(int i=0; i ==(a.Count-1);i )
should be for(int i=0; i < a.Count; i )
The for loop executes and iterates as long as the condition (second "part") resolves to true.
In your original code, it does not: 0 does not equal a.Count-1, so the loop body is not executed even once.