We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
classResult{/* * Complete the 'beautifulDays' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER i * 2. INTEGER j * 3. INTEGER k */publicstaticintbeautifulDays(inti,intj,intk){// Write your code hereinttotal=0;for(;i<=j;i++){inttemp=i;intrev=0;while(temp!=0){intlst=temp%10;temp=temp/10;rev=rev*10+lst;}intdiff=Math.abs(i-rev);if(diff%k==0){total++;}}returntotal;}}
Cookie support is required to access HackerRank
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 →
Simple Java Solution