Find Punishment Number Of An Integer In 60 Characters
Iterate through integers 1-n, compute square and check if it can be partitioned into substrings that sum up to the integer using recursive helper function.
2698. Find the Punishment Number of an Integer Difficulty: Medium Topics: Math, Backtracking 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 integers i in the range [1, 10] that satisfy the conditions in the statement: 1 since 1 * 1 = 1 9 since 9 * 9 = 8...