dont know why all the test cases are not passing
#include
#include<math.h>
using namespace std;
int happy(int n,int m)
{
int arr[n+1];
arr[0]=0;
for(int i=1;i<=n;i++)
{
if(i>m)
arr[i]=arr[i-1];
else if(i<m)
arr[i]=1;
else
arr[i]=2;
}
return arr[n];
}
int main()
{
int t;
cin>>t;
while(t>0)
{
int n,m;
cin>>n>>m;
cout<<((happy(n,m))%1000000007)<<endl;
t–;
}
}
Https://online.codingblocks.com/player/16664/content/5208?tab=submissions
I think u pasted the same query again.It is already running on other thread