My solution is showed below. It costs 412 ms. But I think the time complexity is n*sqrt(n), right? I know it would be faster if using `static`

keyword but if submit it, it shows a Runtime Error. However, it passes single test by "Run Code" button. How should I use `static`

keyword in my code? Thank you in advance.

```
class Solution {
public:
int numSquares(int n) {
vector<int> dp(n + 1, n + 1);
int square = 2;
dp[0] = 0;
dp[1] = 1;
for (int i = 2; i <= n; i++) {
if (i == square * square) {
dp[i] = 1;
square++;
}
else {
for (int j = square - 1; j > 0; j--) {
dp[i] = min(dp[i], 1 + dp[i - j * j]);
}
}
}
return dp[n];
}
};
```