Three points:
Sequences define the structure of choices in DP problems. Here, the sequence of perfect squares determines which transitions are valid.
Algebraic manipulation (solving for ) gives you loop bounds. This prevents checking invalid values.
Time complexity analysis uses summation formulas. The term approximates to .