title: Number Of Binary Trees For Given Preorder Sequence Length
signature: def number_of_binary_trees_for_given_preorder_sequence_length(n):
source_py: def number_of_binary_trees_for_given_preorder_sequence_length(n):
      BT = ([0] * (n + 1))
      BT[0] = BT[1] = 1
      for i in range(2, (n + 1)):
          for j in range(i):
              BT[i] += (BT[j] * BT[((i - j) - 1)])
      return BT[n]
source_cpp: int number_of_binary_trees_for_given_preorder_sequence_length(int n) {
    int BT [ n + 1 ];
    memset ( BT, 0, sizeof ( BT ) );
    BT [ 0 ] = BT [ 1 ] = 1;
    for ( int i = 2;
    i <= n;
    ++ i ) for ( int j = 0;
    j < i;
    j ++ ) BT [ i ] += BT [ j ] * BT [ i - j - 1 ];
    return BT [ n ];
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(n, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              n),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver(15, 9694845)
      print(f"TEST-0...{result}")
  
      result = driver(11, 58786)
      print(f"TEST-1...{result}")
  
      result = driver(11, 58786)
      print(f"TEST-2...{result}")
  
      result = driver(15, 9694845)
      print(f"TEST-3...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3']
question_info.entry_fn_name: number_of_binary_trees_for_given_preorder_sequence_length
question_info.test_list: [{"idx": 0, "outputs": 9694845, "inputs": {"n": 15}}, {"idx": 1, "outputs": 58786, "inputs": {"n": 11}}, {"idx": 2, "outputs": 58786, "inputs": {"n": 11}}, {"idx": 3, "outputs": 9694845, "inputs": {"n": 15}}]
question_info.entry_cls_name: Solution