title: Square Root Of An Integer 1
signature: class Solution {
  
      public Integer squareRootOfAnInteger1(Integer x) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer x, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(x,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(40, 6);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(10, 3);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(46, 6);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(54, 7);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(1, 1);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(67, 8);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(64, 8);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(10, 3);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(75, 8);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(11, 3);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer x, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(x),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def square_root_of_an_integer_1(x):
      if ((x == 0) or (x == 1)):
          return x
      start = 1
      end = x
      while (start <= end):
          mid = ((start + end) // 2)
          if ((mid * mid) == x):
              return mid
          if ((mid * mid) < x):
              start = (mid + 1)
              ans = mid
          else:
              end = (mid - 1)
      return ans
source_cpp: int square_root_of_an_integer_1(int x) {
    if ( x == 0 || x == 1 ) return x;
    int start = 1, end = x, ans;
    while ( start <= end ) {
      int mid = ( start + end ) / 2;
      if ( mid * mid == x ) return mid;
      if ( mid * mid < x ) {
        start = mid + 1;
        ans = mid;
      }
      else end = mid - 1;
    }
    return ans;
  }