Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b05d77

Browse files
refactor 633
1 parent8d106db commit5b05d77

File tree

1 file changed

+19
-15
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+19
-15
lines changed
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
packagecom.fishercoder.solutions;
22

33
/**
4+
* 633. Sum of Square Numbers
5+
*
46
* Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c.
57
68
Example 1:
@@ -13,22 +15,24 @@
1315
Output: False
1416
*/
1517
publicclass_633 {
16-
publicbooleanjudgeSquareSum(intc) {
17-
if (c <0) {
18-
returnfalse;
19-
}
20-
intleft =0;
21-
intright = (int) (Math.sqrt(c));
22-
while (left <=right) {
23-
intcurr =left *left +right *right;
24-
if (curr >c) {
25-
right--;
26-
}elseif (curr <c) {
27-
left++;
28-
}else {
29-
returntrue;
18+
publicstaticclassSolution1 {
19+
publicbooleanjudgeSquareSum(intc) {
20+
if (c <0) {
21+
returnfalse;
3022
}
23+
intleft =0;
24+
intright = (int) (Math.sqrt(c));
25+
while (left <=right) {
26+
intcurr =left *left +right *right;
27+
if (curr >c) {
28+
right--;
29+
}elseif (curr <c) {
30+
left++;
31+
}else {
32+
returntrue;
33+
}
34+
}
35+
returnfalse;
3136
}
32-
returnfalse;
3337
}
3438
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp