You are viewing a single comment's thread. Return to all comments →
another approach !
if (i < 1 || j < 1 || k < 1) return -1; int count = 0; for (int n = i; n <= j; n++) { String wordInt = String.valueOf(n); int y = wordInt.length() - 1; String reverse = ""; while (y >= 0) { reverse = reverse + wordInt.charAt(y); y--; } int num = Integer.parseInt(reverse); int difference = Math.abs(num - n); if (difference % k == 0) { count++; } } return count;
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 →
another approach !