Sum of Square Numbers
Medium · Math, Two Pointers, Binary Search
Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.
Example 1
Input: c = 5 Output: true
1 * 1 + 2 * 2 = 5
Example 2
Input: c = 3 Output: false
Constraints
- 0 <= c <= 231 - 1
Starter code (python)
class Solution(object):
def judgeSquareSum(self, c):
"""
:type c: int
:rtype: bool
"""
Related problems
- Add Two Numbers (Medium)
- Median of Two Sorted Arrays (Hard)
- Longest Palindromic Substring (Medium)
Previous: Course Schedule III · Next: Exclusive Time of Functions · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.