title: Check Occurrences Character Appear Together
signature: func checkOccurrencesCharacterAppearTogether(s string, c rune) 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(s string, c rune, expected bool) string {
      if validateSolution(PLACEHOLDER_FN_NAME(s, c),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver("gILrzLimS", 
  	'm', true)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver("307471222", 
  	'2', true)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver("110", 
  	'0', true)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver("GcAB", 
  	'v', true)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver("113", 
  	'3', true)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver("011110010", 
  	'0', false)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver("wcwob", 
  	'w', false)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver("74571582216153", 
  	'1', false)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver("100000011", 
  	'0', true)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver("ryPErkzY", 
  	'q', true)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
  }