title: Length Longest Sub String Can Make Removed
signature: class Solution {
  
      public Integer lengthLongestSubStringCanMakeRemoved(String 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.extension: java
question_info.entry_fn_name: lengthLongestSubStringCanMakeRemoved
question_info.entry_cls_name: Solution
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 "}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String s, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(s,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("U", 0);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("544", 0);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("111", 0);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(" cDQaNxpRSOe", 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("42920062459", 0);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("00100101", 3);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("FiC", 0);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("302746335230", 0);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("1", 0);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("ZBLHiwGreUR ", 0);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String s, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(s),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__