Skip to content

Commit

Permalink
Automated Commit 🤖
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 31, 2024
1 parent 3ee944d commit a22703d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ LeetCode/
| 2239 | [Find Closest Number to Zero](https://leetcode.com/problems/find-closest-number-to-zero/description/) | [Python](src/2239-find-closest-number-to-zero.md) |
| 1342 | [Number of Steps to Reduce a Number to Zero](https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/description/) | [Python](src/1342-number-of-steps-to-reduce-a-number-to-zero.md) |
| 169 | [Majority Element](https://leetcode.com/problems/majority-element/description/) | [Python](src/169-majority-element.md) |
| 231 | [Power of Two](https://leetcode.com/problems/power-of-two/description/) | [Python](src/231-power-of-two.md) |
| 231 | [Power of Two](https://leetcode.com/problems/power-of-two/description/) | [Python](src/231-power-of-two.md) |


## Medium

| ID | Title | Solution |
|----|------------------------------------|----------|
| 633 | [Sum of Square Numbers](https://leetcode.com/problems/sum-of-square-numbers/description/) | [Python](src/633-sum-of-square-numbers.md) |
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ <h2>Easy</h2>
| 169 | <a href="https://leetcode.com/problems/majority-element/description/">Majority Element</a> | <a href="src/169-majority-element.md">Python</a> |
| 231 | <a href="https://leetcode.com/problems/power-of-two/description/">Power of Two</a> | <a href="src/231-power-of-two.md">Python</a> |</p>

<h2>Medium</h2>

<p>| ID | Title | Solution |
|----|------------------------------------|----------|
| 633 | <a href="https://leetcode.com/problems/sum-of-square-numbers/description/">Sum of Square Numbers</a> | <a href="src/633-sum-of-square-numbers.md">Python</a> |</p>

</body>
</html>

49 changes: 49 additions & 0 deletions src/633-sum-of-square-numbers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Sum of Square Numbers
**URL**: [https://leetcode.com/problems/sum-of-square-numbers/description/](https://leetcode.com/problems/sum-of-square-numbers/description/)

**Description:**

Given a non-negative integer c, decide whether there're two integers a and b
such that a^2 + b^2 = c.

__Example 1:__
```
Input: c = 5
Output: true
Explanation: 1 * 1 + 2 * 2 = 5
```

__Example 2:__
```
Input: c = 3
Output: false
```

__Constraints:__
```
0 <= c <= 2^31 - 1
```

**Solution Code**:
```python
from math import sqrt

class Solution:
def judgeSquareSum(self, c: int) -> bool:
a = 0
b = int(sqrt(c))

if c <= 2:
return True

while (a<=b):
result = (a*a) + (b*b)
if result == c:
return True
if result < c:
a += 1
else:
b -= 1
return False

```

0 comments on commit a22703d

Please sign in to comment.