Ctrl K

Palindrome From Two Factors

Hard
Take two integers, each with exactly width digits (no leading zeros), and multiply them. Among all such products, find the largest one that is a palindrome, meaning it reads the same forwards and backwards. The number can be huge, so return it modulo 1337.
Example 1
width=2 → 987

The largest palindrome is 9009 = 99 · 91, and 9009 mod 1337 is 987.

Example 2
width=1 → 9

With one-digit factors the best palindrome is 9 = 1 · 9 (or 3 · 3).

Example 3
width=3 → 123
Constraints
  • 1 ≤ width ≤ 8
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSums of Consecutive Numbers HardMirror Squares in a Range HardWhere Moss Species Meet HardPalindromes in Two Bases HardSplit a Tree Into Equal Parts Hard
loading Python…
Input
width=2
Expected
987

Run checks the first 3 tests in your browser. Submit checks all 11 tests on the server, hidden ones included.