title: Check Occurrences Character Appear Together
signature: check_occurrences_character_appear_together <- function(s, c) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(s, c, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(s, c), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          "gILrzLimS", 'm', 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          "307471222", '2', 
          TRUE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          "110", '0', 
          TRUE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          "GcAB", 'v', 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          "113", '3', 
          TRUE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          "011110010", '0', 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          "wcwob", 'w', 
          FALSE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          "74571582216153", '1', 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          "100000011", '0', 
          TRUE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          "ryPErkzY", 'q', 
          TRUE
      )))
  
  }
  
  main()
source_py: def check_occurrences_character_appear_together(s, c):
      oneSeen = False
      i = 0
      n = len(s)
      while (i < n):
          if (s[i] == c):
              if (oneSeen == True):
                  return False
              while ((i < n) and (s[i] == c)):
                  i = (i + 1)
              oneSeen = True
          else:
              i = (i + 1)
      return True
source_cpp: bool check_occurrences_character_appear_together(string s, char c) {
    bool oneSeen = false;
    int i = 0, n = s . length ( );
    while ( i < n ) {
      if ( s [ i ] == c ) {
        if ( oneSeen == true ) return false;
        while ( i < n && s [ i ] == c ) i ++;
        oneSeen = true;
      }
      else i ++;
    }
    return true;
  }