So I have a solution with an if statement which passes all subtasks and wanted to try it with the ternary operator which I expected to pass too. Now the suprise was, it fails and I don’t know what exactly the problem is. The error message is not really helping me.
Hope anyone can explain why it’s not working.
If you are finding Maximum, then after each change if condition becomes true it will replace it with ‘0’, which should not be the case as Maximum will remain same as previous Maximum.
so change it to :
maxScore = (goals[j] * 20 - fouls[j] * 10 > maxScore) ? goals[j] * 20 - fouls[j] * 10 : maxScore;