Skip to content

Commit 6d591de

Browse files
committed
Solution as on 21-04-2022 06:58 pm
1 parent 5fb6677 commit 6d591de

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

0633. Sum of Square Numbers.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// 633.✅ Sum of Square Numbers
2+
3+
class Solution
4+
{
5+
public:
6+
bool judgeSquareSum(int c)
7+
{
8+
9+
if (c < 0)
10+
return false;
11+
long int start = 0;
12+
long int end = sqrt(c);
13+
14+
while (start <= end)
15+
{
16+
long int curr = start * start + end * end;
17+
if (curr < c)
18+
++start;
19+
else if (curr > c)
20+
--end;
21+
else
22+
return true;
23+
}
24+
25+
return false;
26+
}
27+
};

0 commit comments

Comments
 (0)