You are viewing a single comment's thread. Return to all comments →
static int beautifulDays(int i, int j, int k) { int r=0,count=0;
int l=Math.abs(i-j)+1; int[] ar=new int[l]; int[] ar1=new int[l]; int[] sum=new int[l]; int n=i; for(int m=0;m<ar.length;m++) { ar[m]=i; i++; ar1[m]=n; n++; sum[m]=0; while(ar[m]>0) { r=ar[m]%10; sum[m]=sum[m]*10 + r; ar[m]=ar[m]/10; } if(((Math.abs(ar1[m]-sum[m]))%k)==0) count++; } return count; } Performed similar logic but without String builder class.
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Days at the Movies
You are viewing a single comment's thread. Return to all comments →
static int beautifulDays(int i, int j, int k) { int r=0,count=0;