Medium
Perfect Squares
Medium
59 submissions
25 coins
+100 XP
Dynamic Programming
Math
Problem Description
Return the minimum number of perfect squares (1, 4, 9, 16, …) that sum to `n`.
**Example 1:**
```
Input: n = 12
Output: 3
```
**Example 2:**
```
Input: n = 13
Output: 2
```
**Example 3:**
```
Input: n = 1
Output: 1
```
Constraints
- `1 <= n <= 10^4`
Need help?
Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.
Video Call
Whiteboard
Live Coding
Screen Share