title: Smallest Power Of 2 Greater Than Or Equal To N 1
signature: class Solution {
  
      public Integer smallestPowerOf2GreaterThanOrEqualToN1(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, Integer 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(31, 32);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(89, 128);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(92, 128);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(66, 128);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(38, 64);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(34, 64);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(17, 32);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(24, 32);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(54, 64);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(20, 32);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def smallest_power_of_2_greater_than_or_equal_to_n_1(n):
      p = 1
      if (n and (not (n & (n - 1)))):
          return n
      while (p < n):
          p <<= 1
      return p
source_cpp: unsigned int smallest_power_of_2_greater_than_or_equal_to_n_1(unsigned int n) {
    unsigned int p = 1;
    if ( n && ! ( n & ( n - 1 ) ) ) return n;
    while ( p < n ) p <<= 1;
    return p;
  }