Let’s count the number of fives and twos in the string.
If there are more fives than twos, print ;
If there are more twos than fives, print ;
If the number of twos and fives is equal, print the equality symbol '';
Algorithm implementation
Read the input string.
cin >> s;Compute the number of fives and twos in the string .
fives = twos = 0;
for (i = 0; i < s.size(); i++)
if (s[i] == '2') twos++; else fives++;Print the answer.
if (fives > twos) cout << "5"; else
if (fives < twos) cout << "2";
else cout << "=";
cout << endl;Python implementation
Read the input string.
s = input()Compute the number of fives and twos in the string .
fives = s.count('5')
twos = s.count('2')Print the answer.
if fives > twos:
print("5")
elif fives < twos:
print("2")
else:
print("=")