I don’t understand what I’ve to do under Subtasks 1 and 2. Can someone help me out? I have identified the frequency of 4s present in my numeral and that part works perfectly
int main()
{
int t;
cin>>t;
cin.ignore();
while(t–){
string s;
cin>>s;
int count=0;
for (int i = 0; i < s.size(); ++i)
{
if ((s[i]-‘0’)==4)
{
count=count+1;
}
}
Okay so what I did is I took the input of each test case as string and ran a for loop from 0 to length of the string -1 and compared each of the index of string string with 4 whenever I found 4 I increased the count and finally printed the count
process.stdin.on(‘data’, data => {
let userInput = data.toString();
let long = userInput.replace(/\s/g,".");
let arr = long.split(’.’);
const t = arr[0];
let a = 0;
let par1 = 1;
let count = 0;
for (let i = 0; i < t; i++){
a = arr[par1].split('');
for(let i = 0; i < a.length; i++){
if (a[i] === '4'){
count += 1;
}
}
console.log(count);
par1 += 1;
count = 0;
}
process.exit();
(Subtask 1): 0 ≤ Numbers from the list ≤ 9 - 33 points.
(Subtask 2): 0 ≤ Numbers from the list ≤ 109- 67 points.
i don’t understand what subtask 1 and 2 mean here?
I was using C++ and in the reference code they used long long for all variables instead of int. why is it so?
without using long long , my code got submitted.