Faling test case 2 and 3
add one condition
if( a==0) a=1;
this is because when a==0 you are accessing a[-1] which will give error
cout<<cnt[b]-cnt[a-1]<<endl;
Modified Code
now it will pass all testcase
if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like
: and don’t forgot to mark doubt as resolved 