I attempted the solution in the below way, i am new to codechef, can anyone tell me why i am getting the error time limit exceeded. Have pasted the code below.
#include “iostream”
#include “list”
using namespace std;
int main()
{
list tList;
list::iterator it;
int t, n, x;
cin >> t;
while (t--)
{
int count = 0;
cin >> n;
tList.push_back(n);
for (it = tList.begin(); it != tList.end(); ++it)
{
while (*it != 0)
{
x = *it % 10;
if (x == 4)
{
count++;
}
*it /= 10;
}
}
cout << count << endl;
}
return 0;
}