Tap here to switch tabs
Problem
Ask
Submissions

Problem: Perfect Squares

med
30 min
Explore how to determine the minimum count of perfect square numbers that add up to a given integer. Learn to identify perfect squares and apply mathematical reasoning paired with coding patterns to solve this common interview problem efficiently.

Statement

Given an integer, n, return the least number of perfect square numbers that sum to n.

A perfect square is an integer that is the square of an integer. In other words, it is an integer that is the result of multiplying a whole integer by itself. For example, 11, 44, 99, and 1616 are perfect squares, but 33, 55, and 1111 are not.

Constraints:

  • 11 \leq n 103\leq 10^3

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Perfect Squares

med
30 min
Explore how to determine the minimum count of perfect square numbers that add up to a given integer. Learn to identify perfect squares and apply mathematical reasoning paired with coding patterns to solve this common interview problem efficiently.

Statement

Given an integer, n, return the least number of perfect square numbers that sum to n.

A perfect square is an integer that is the square of an integer. In other words, it is an integer that is the result of multiplying a whole integer by itself. For example, 11, 44, 99, and 1616 are perfect squares, but 33, 55, and 1111 are not.

Constraints:

  • 11 \leq n 103\leq 10^3