title: Find Whether A Given Number Is A Power Of 4 Or Not 1
signature: class Solution {
  
      public Boolean findWhetherAGivenNumberIsAPowerOf4OrNot1(Integer n) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(Integer n, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(1, true);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(4, true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(64, true);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(-64, false);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(128, false);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(1024, true);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(45, false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(33, false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(66, false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(74, false);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def find_whether_a_given_number_is_a_power_of_4_or_not_1(n):
      count = 0
      if (n and (not (n & (n - 1)))):
          while (n > 1):
              n >>= 1
              count += 1
          if ((count % 2) == 0):
              return True
          else:
              return False
source_cpp: bool find_whether_a_given_number_is_a_power_of_4_or_not_1(unsigned int n) {
    int count = 0;
    if ( n && ! ( n & ( n - 1 ) ) ) {
      while ( n > 1 ) {
        n >>= 1;
        count += 1;
      }
      return ( count % 2 == 0 ) ? 1 : 0;
    }
    return 0;
  }