title: Longest Common Increasing Subsequence Lcs Lis
signature: function longestCommonIncreasingSubsequenceLcsLis(arr1: Array<number>, n: number, arr2: Array<number>, m: number): number {
source_py: def longest_common_increasing_subsequence_lcs_lis(arr1, n, arr2, m):
      table = ([0] * m)
      for j in range(m):
          table[j] = 0
      for i in range(n):
          current = 0
          for j in range(m):
              if (arr1[i] == arr2[j]):
                  if ((current + 1) > table[j]):
                      table[j] = (current + 1)
              if (arr1[i] > arr2[j]):
                  if (table[j] > current):
                      current = table[j]
      result = 0
      for i in range(m):
          if (table[i] > result):
              result = table[i]
      return result
source_cpp: int longest_common_increasing_subsequence_lcs_lis(vector<int> arr1, int n, vector<int> arr2, int m) {
    int table [ m ];
    for ( int j = 0;
    j < m;
    j ++ ) table [ j ] = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      int current = 0;
      for ( int j = 0;
      j < m;
      j ++ ) {
        if ( arr1 [ i ] == arr2 [ j ] ) if ( current + 1 > table [ j ] ) table [ j ] = current + 1;
        if ( arr1 [ i ] > arr2 [ j ] ) if ( table [ j ] > current ) current = table [ j ];
      }
    }
    int result = 0;
    for ( int i = 0;
    i < m;
    i ++ ) if ( table [ i ] > result ) result = table [ i ];
    return result;
  }
question_info.test_list: [{"idx": 0, "outputs": 0, "inputs": {"arr1": [1, 7, 9, 35, 43, 51, 51, 66, 88], "n": 5, "arr2": [10, 21, 38, 50, 65, 67, 87, 93, 99], "m": 8}}, {"idx": 1, "outputs": 1, "inputs": {"arr1": [-52, 52, -92, -46, -94, 30, -36, 18, -98, 22, -36, 96, -88, -50, 50], "n": 7, "arr2": [-58, 40, 56, -62, -92, -94, 40, 18, -2, -76, -78, -14, 44, 84, 4], "m": 10}}, {"idx": 2, "outputs": 2, "inputs": {"arr1": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 36, "arr2": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "m": 22}}, {"idx": 3, "outputs": 0, "inputs": {"arr1": [5, 74, 29], "n": 1, "arr2": [57, 33, 48], "m": 1}}, {"idx": 4, "outputs": 0, "inputs": {"arr1": [-84, -74, -70, -62, -56, -56, -52, -2, 6, 24, 28, 44, 44, 52], "n": 8, "arr2": [-98, -96, -88, -66, -32, -26, -24, -20, -4, 20, 48, 74, 90, 96], "m": 12}}, {"idx": 5, "outputs": 2, "inputs": {"arr1": [0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0], "n": 17, "arr2": [1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0], "m": 15}}, {"idx": 6, "outputs": 4, "inputs": {"arr1": [3, 4, 4, 7, 15, 15, 16, 22, 32, 32, 37, 39, 39, 41, 43, 46, 47, 47, 49, 75, 79, 80, 86, 88, 93], "n": 19, "arr2": [9, 12, 15, 20, 22, 27, 28, 28, 30, 31, 35, 39, 47, 58, 58, 60, 73, 74, 76, 78, 80, 86, 95, 96, 98], "m": 14}}, {"idx": 7, "outputs": 1, "inputs": {"arr1": [70, -64, 0, 52, 32, -98, 38, -8, 34, 70, 98, 58, -48, -60, -28, -22, -72, 82, -98, -36], "n": 16, "arr2": [-18, 88, -40, -52, 30, -10, -18, -56, 84, -22, -64, 80, -14, -64, 40, 92, 48, -8, 24, 82], "m": 12}}, {"idx": 8, "outputs": 2, "inputs": {"arr1": [0, 0, 1, 1, 1, 1, 1, 1], "n": 7, "arr2": [0, 1, 1, 1, 1, 1, 1, 1], "m": 7}}, {"idx": 9, "outputs": 0, "inputs": {"arr1": [46, 87, 98], "n": 2, "arr2": [67, 31, 54], "m": 2}}]
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(arr1: Array<number>, n: number, arr2: Array<number>, m: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(arr1, n, arr2, m),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([1, 7, 9, 35, 43, 51, 51, 66, 88], 5, [10, 21, 38, 50, 65, 67, 87, 93, 99], 8, 0);
    console.log(`TEST-0...${result}`);
  
    result = driver([-52, 52, -92, -46, -94, 30, -36, 18, -98, 22, -36, 96, -88, -50, 50], 7, [-58, 40, 56, -62, -92, -94, 40, 18, -2, -76, -78, -14, 44, 84, 4], 10, 1);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 36, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 22, 2);
    console.log(`TEST-2...${result}`);
  
    result = driver([5, 74, 29], 1, [57, 33, 48], 1, 0);
    console.log(`TEST-3...${result}`);
  
    result = driver([-84, -74, -70, -62, -56, -56, -52, -2, 6, 24, 28, 44, 44, 52], 8, [-98, -96, -88, -66, -32, -26, -24, -20, -4, 20, 48, 74, 90, 96], 12, 0);
    console.log(`TEST-4...${result}`);
  
    result = driver([0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0], 17, [1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0], 15, 2);
    console.log(`TEST-5...${result}`);
  
    result = driver([3, 4, 4, 7, 15, 15, 16, 22, 32, 32, 37, 39, 39, 41, 43, 46, 47, 47, 49, 75, 79, 80, 86, 88, 93], 19, [9, 12, 15, 20, 22, 27, 28, 28, 30, 31, 35, 39, 47, 58, 58, 60, 73, 74, 76, 78, 80, 86, 95, 96, 98], 14, 4);
    console.log(`TEST-6...${result}`);
  
    result = driver([70, -64, 0, 52, 32, -98, 38, -8, 34, 70, 98, 58, -48, -60, -28, -22, -72, 82, -98, -36], 16, [-18, 88, -40, -52, 30, -10, -18, -56, 84, -22, -64, 80, -14, -64, 40, 92, 48, -8, 24, 82], 12, 1);
    console.log(`TEST-7...${result}`);
  
    result = driver([0, 0, 1, 1, 1, 1, 1, 1], 7, [0, 1, 1, 1, 1, 1, 1, 1], 7, 2);
    console.log(`TEST-8...${result}`);
  
    result = driver([46, 87, 98], 2, [67, 31, 54], 2, 0);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: longestCommonIncreasingSubsequenceLcsLis
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