title: Length Longest Sub String Can Make Removed
signature: function length_longest_sub_string_can_make_removed(s)
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;
      }
question_info.entry_fn_name: length_longest_sub_string_can_make_removed
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(s, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(s) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver("U", 0)
      print(string.format("TEST-0...%s",result))
  
      result = driver("544", 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver("111", 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(" cDQaNxpRSOe", 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver("42920062459", 0)
      print(string.format("TEST-4...%s",result))
  
      result = driver("00100101", 3)
      print(string.format("TEST-5...%s",result))
  
      result = driver("FiC", 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver("302746335230", 0)
      print(string.format("TEST-7...%s",result))
  
      result = driver("1", 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver("ZBLHiwGreUR ", 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"s": "U"}}, {"idx": 1, "outputs": 0, "inputs": {"s": "544"}}, {"idx": 2, "outputs": 0, "inputs": {"s": "111"}}, {"idx": 3, "outputs": 0, "inputs": {"s": " cDQaNxpRSOe"}}, {"idx": 4, "outputs": 0, "inputs": {"s": "42920062459"}}, {"idx": 5, "outputs": 3, "inputs": {"s": "00100101"}}, {"idx": 6, "outputs": 0, "inputs": {"s": "FiC"}}, {"idx": 7, "outputs": 0, "inputs": {"s": "302746335230"}}, {"idx": 8, "outputs": 0, "inputs": {"s": "1"}}, {"idx": 9, "outputs": 0, "inputs": {"s": "ZBLHiwGreUR "}}]