Security problem | Sololearn: Learn to code for FREE!


Security problem

my code fails in some test cases. can you help me understand where am I wrong?

3/20/2022 9:17:04 PM

Francesco Famosi

2 Answers

New Answer


$ can be the first or last character


Use variable type "i" size_t instead of int since you are comparing two different value types: for(size_t i=0; i<piano_temp.length(); i++) Better yet, use an improved "for" loop: for(char a: piano_temp) if(a=='G'||a=='$'||a=='T')piano+=a; There are only two cases where an alarm should sound: T$ and $T ๐Ÿ˜‰