title: Number Of Substrings With Odd Decimal Value In A Binary String
signature: function numberOfSubstringsWithOddDecimalValueInABinaryString(s: string): number {
source_py: def number_of_substrings_with_odd_decimal_value_in_a_binary_string(s):
      n = len(s)
      auxArr = [0 for i in range(n)]
      if (s[0] == '1'):
          auxArr[0] = 1
      for i in range(0, n):
          if (s[i] == '1'):
              auxArr[i] = (auxArr[(i - 1)] + 1)
          else:
              auxArr[i] = auxArr[(i - 1)]
      count = 0
      for i in range((n - 1), (- 1), (- 1)):
          if (s[i] == '1'):
              count += auxArr[i]
      return count
source_cpp: int number_of_substrings_with_odd_decimal_value_in_a_binary_string(string s) {
    int n = s . length ( );
    int auxArr [ n ] = {
      0 };
      if ( s [ 0 ] == '1' ) auxArr [ 0 ] = 1;
      for ( int i = 1;
      i < n;
      i ++ ) {
        if ( s [ i ] == '1' ) auxArr [ i ] = auxArr [ i - 1 ] + 1;
        else auxArr [ i ] = auxArr [ i - 1 ];
      }
      int count = 0;
      for ( int i = n - 1;
      i >= 0;
      i -- ) if ( s [ i ] == '1' ) count += auxArr [ i ];
      return count;
    }
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"s": "OGiOkJF"}}, {"idx": 1, "outputs": 1, "inputs": {"s": "517376"}}, {"idx": 2, "outputs": 3, "inputs": {"s": "11"}}, {"idx": 3, "outputs": 0, "inputs": {"s": "Ze"}}, {"idx": 4, "outputs": 1, "inputs": {"s": "8763644247018"}}, {"idx": 5, "outputs": 15, "inputs": {"s": "00111010001"}}, {"idx": 6, "outputs": 0, "inputs": {"s": "HGwkBKUOVu"}}, {"idx": 7, "outputs": 0, "inputs": {"s": "652"}}, {"idx": 8, "outputs": 21, "inputs": {"s": "101000011110"}}, {"idx": 9, "outputs": 0, "inputs": {"s": "kvdpG "}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(s: string, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(s),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver("OGiOkJF", 0);
    console.log(`TEST-0...${result}`);
  
    result = driver("517376", 1);
    console.log(`TEST-1...${result}`);
  
    result = driver("11", 3);
    console.log(`TEST-2...${result}`);
  
    result = driver("Ze", 0);
    console.log(`TEST-3...${result}`);
  
    result = driver("8763644247018", 1);
    console.log(`TEST-4...${result}`);
  
    result = driver("00111010001", 15);
    console.log(`TEST-5...${result}`);
  
    result = driver("HGwkBKUOVu", 0);
    console.log(`TEST-6...${result}`);
  
    result = driver("652", 0);
    console.log(`TEST-7...${result}`);
  
    result = driver("101000011110", 21);
    console.log(`TEST-8...${result}`);
  
    result = driver("kvdpG ", 0);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: numberOfSubstringsWithOddDecimalValueInABinaryString
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js