title: Write An Efficient Method To Check If A Number Is Multiple Of 3
signature: class Solution {
  
      public Integer writeAnEfficientMethodToCheckIfANumberIsMultipleOf3(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(94, 0);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(94, 0);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(79, 0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(39, 1);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(16, 0);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(90, 1);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(64, 0);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(76, 0);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(83, 0);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(47, 0);
          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 write_an_efficient_method_to_check_if_a_number_is_multiple_of_3(n):
      odd_count = 0
      even_count = 0
      if (n < 0):
          n = (- n)
      if (n == 0):
          return 1
      if (n == 1):
          return 0
      while n:
          if (n & 1):
              odd_count += 1
          if (n & 2):
              even_count += 1
          n = (n >> 2)
      return write_an_efficient_method_to_check_if_a_number_is_multiple_of_3(abs((odd_count - even_count)))
source_cpp: int write_an_efficient_method_to_check_if_a_number_is_multiple_of_3(int n) {
    int odd_count = 0;
    int even_count = 0;
    if ( n < 0 ) n = - n;
    if ( n == 0 ) return 1;
    if ( n == 1 ) return 0;
    while ( n ) {
      if ( n & 1 ) odd_count ++;
      if ( n & 2 ) even_count ++;
      n = n >> 2;
    }
    return write_an_efficient_method_to_check_if_a_number_is_multiple_of_3 ( abs ( odd_count - even_count ) );
  }