title: Check String Follows Anbn Pattern Not
signature: func checkStringFollowsAnbnPatternNot(str string) bool {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual bool, expected bool) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(str string, expected bool) string {
      if validateSolution(PLACEHOLDER_FN_NAME(str),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver("ba", false)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver("aabb", true)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver("abab", false)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver("aaabb", false)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver("aabbb", false)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver("abaabbaa", false)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver("abaababb", false)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver("bbaa", false)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver("11001000", false)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver("ZWXv te", false)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
  }