Leetcode Problem 633. Sum of Square Numbers

633. Sum of Square Numbers

Leetcode Solutions

Approach: Using Sqrt Function

  1. Start with a = 0.
  2. While a is less than or equal to sqrt(c), do the following steps: a. Calculate b_squared = c - a * a. b. Calculate b = sqrt(b_squared). c. Check if b is an integer (i.e., b - floor(b) == 0). If it is, return true. d. Increment a by 1.
  3. If no such a is found, return false.
UML Thumbnail

Approach: Brute Force

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...