package com.fishercoder.solutions;

/**
 * Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c.

 Example 1:
 Input: 5
 Output: True
 Explanation: 1 * 1 + 2 * 2 = 5

 Example 2:
 Input: 3
 Output: False
 */
public class _633 {
    public boolean judgeSquareSum(int c) {
        if (c < 0) {
            return false;
        }
        int left = 0;
        int right = (int) (Math.sqrt(c));
        while (left <= right) {
            int curr = left * left + right * right;
            if (curr > c) {
                right--;
            } else if (curr < c) {
                left++;
            } else {
                return true;
            }
        }
        return false;
    }
}

@@ -33,16 +33,49 @@
 s;%0A%0A/**%0A
+ * 633. Sum of Square Numbers%0A *%0A
  * Given
@@ -316,16 +316,56 @@
  _633 %7B%0A
+    public static class Solution1 %7B%0A    
     publ
@@ -403,24 +403,28 @@
 ) %7B%0A        
+ 
+   
 if (c %3C 0) %7B
@@ -420,24 +420,28 @@
 f (c %3C 0) %7B%0A
+    
             
@@ -454,34 +454,42 @@
  false;%0A        
+   
+ 
 %7D%0A
+    
         int left
@@ -494,16 +494,20 @@
 ft = 0;%0A
+    
         
@@ -548,16 +548,20 @@
         
+    
 while (l
@@ -572,24 +572,28 @@
 %3C= right) %7B%0A
+    
             
@@ -640,24 +640,28 @@
             
+ 
+   
 if (curr %3E c
@@ -680,16 +680,20 @@
         
+    
 right--;
@@ -701,24 +701,28 @@
             
+  
+  
 %7D else if (c
@@ -748,16 +748,20 @@
         
+    
 left++;%0A
@@ -768,24 +768,28 @@
             
+   
+ 
 %7D else %7B%0A   
@@ -785,16 +785,20 @@
  else %7B%0A
+    
         
@@ -818,16 +818,20 @@
 n true;%0A
+    
         
@@ -836,34 +836,42 @@
       %7D%0A        
-%7D%0A
+    %7D%0A    
         return f
@@ -872,20 +872,30 @@
 turn false;%0A
+        %7D%0A
     %7D%0A%7D%0A

refactor 633