title: Length Longest Sub String Can Make Removed
signature: function length_longest_sub_string_can_make_removed(s)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(s, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(s), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver("U", 0);
      @printf("TEST-0...%s\n",result);
      
      result = driver("544", 0);
      @printf("TEST-1...%s\n",result);
      
      result = driver("111", 0);
      @printf("TEST-2...%s\n",result);
      
      result = driver(" cDQaNxpRSOe", 0);
      @printf("TEST-3...%s\n",result);
      
      result = driver("42920062459", 0);
      @printf("TEST-4...%s\n",result);
      
      result = driver("00100101", 3);
      @printf("TEST-5...%s\n",result);
      
      result = driver("FiC", 0);
      @printf("TEST-6...%s\n",result);
      
      result = driver("302746335230", 0);
      @printf("TEST-7...%s\n",result);
      
      result = driver("1", 0);
      @printf("TEST-8...%s\n",result);
      
      result = driver("ZBLHiwGreUR ", 0);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
source_py: def length_longest_sub_string_can_make_removed(S):
      arr = []
      arr.append(['@', (- 1)])
      maxlen = 0
      for i in range(len(S)):
          arr.append([S[i], i])
          while ((len(arr) >= 3) and (arr[(len(arr) - 3)][0] == '1') and (arr[(len(arr) - 2)][0] == '0') and (arr[(len(arr) - 1)][0] == '0')):
              arr.pop()
              arr.pop()
              arr.pop()
          tmp = arr[(- 1)]
          maxlen = max(maxlen, (i - tmp[1]))
      return maxlen
source_cpp: int length_longest_sub_string_can_make_removed(string str) {
    vector < pair < char, int > > arr;
    arr . push_back ( {
      '@', - 1 }
      );
      int maxlen = 0;
      for ( int i = 0;
      i < str . length ( );
      ++ i ) {
        arr . push_back ( {
          str [ i ], i }
          );
          while ( arr . size ( ) >= 3 && arr [ arr . size ( ) - 3 ] . first == '1' && arr [ arr . size ( ) - 2 ] . first == '0' && arr [ arr . size ( ) - 1 ] . first == '0' ) {
            arr . pop_back ( );
            arr . pop_back ( );
            arr . pop_back ( );
          }
          int tmp = arr . back ( ) . second;
          maxlen = max ( maxlen, i - tmp );
        }
        return maxlen;
      }