Fewest Square Numbers Summing to n

Asked at Pinduoduo · Coding Questions · Difficulty: Medium

Every positive integer can be written as a sum of perfect squares (`1, 4, 9, 16, ...`), usually in many ways. Your task is to find a way that uses as few squares as possible, and to return the squares themselves, not only how many there are.

Loading the problem…