← All problemsSign in

2698. Find the Punishment Number of an Integer

LeetCodeMathBacktrackingOpen on judge ↗

Given a positive integer n, return the punishment number of n. The punishment number of n is defined as the sum of the squares of all integers i such that: - 1 <= i <= n - The decimal representation of i * i can be partitioned into contiguous substrings such that the sum of the integer values of these substrings equals i. Example 1: Input: n = 10 Output: 182 Explanation: There are exactly 3

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start