SMALLCASE Off-Campus OA (2025) | Find the Largest Palindrome Divisible by K Problem
Question · Posted Jun 2026
Problem Statement Given two integers n and k, find the largest palindrome consisting of exactly n digits that is divisible by k. Digits can only be from 1 to 9 (no leading zeros allowed). Return the palindrome as a string. Example Input n = 3 k = 5 Output "595" Explanation Possible 3-digit palindromes divisible by 5: 595 585 575 ... The largest one is: 595 Constraints 1 <= n <= 9 1 <= k <= 9
The full answer & interview discussion are available to premium members.
Log in Create a free account