title: Check String Follows Anbn Pattern Not
signature: class Solution {
  
      public Boolean checkStringFollowsAnbnPatternNot(String str) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String str, Boolean expected){
          try{
              Driver driver = new Driver();
              if (driver.run(str,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("ba", false);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("aabb", true);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("abab", false);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("aaabb", false);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("aabbb", false);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("abaabbaa", false);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("abaababb", false);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("bbaa", false);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("11001000", false);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("ZWXv te", false);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String str, Boolean expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(str),expected);
      }
      
      public boolean validateSolution(Boolean actual, Boolean expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
source_py: def check_string_follows_anbn_pattern_not(str):
      n = len(str)
      for i in range(n):
          if (str[i] != 'a'):
              break
      if ((i * 2) != n):
          return False
      for j in range(i, n):
          if (str[j] != 'b'):
              return False
      return True
source_cpp: bool check_string_follows_anbn_pattern_not(string str) {
    int n = str . length ( );
    int i;
    for ( i = 0;
    i < n;
    i ++ ) if ( str [ i ] != 'a' ) break;
    if ( i * 2 != n ) return false;
    int j;
    for ( j = i;
    j < n;
    j ++ ) if ( str [ j ] != 'b' ) return false;
    return true;
  }