title: Check Occurrences Character Appear Together
signature: bool checkOccurrencesCharacterAppearTogether(string s, char c) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(bool actual, bool expected){
      return actual == expected;
  }
  
  string driver(string s, char c, bool expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(s, c), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver("gILrzLimS", 'm', true); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver("307471222", '2', true); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver("110", '0', true); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver("GcAB", 'v', true); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver("113", '3', true); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver("011110010", '0', false); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver("wcwob", 'w', false); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver("74571582216153", '1', false); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver("100000011", '0', true); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver("ryPErkzY", 'q', true); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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;
  }