title: Longest Increasing Odd Even Subsequence
signature: longest_increasing_odd_even_subsequence <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(7L, 8L, 9L, 16L, 16L, 27L, 32L, 33L, 35L, 35L, 39L, 39L, 41L, 42L, 44L, 47L, 48L, 50L, 56L, 59L, 66L, 69L, 70L, 73L, 74L, 76L, 78L, 87L, 87L, 89L, 94L, 96L, 96L, 98L, 98L), 32L, 
          18L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(40L, 76L, -54L, -92L, -28L, -96L, 8L, 60L, 28L, -38L, -62L, -40L, -16L, 16L, 52L, 28L, 70L, -56L, -50L, 46L, 68L, -16L, -56L, 46L, 42L, 70L, 52L, -34L, 86L, -32L, -50L, 64L, 36L, 54L, 20L, 82L, 84L), 25L, 
          1L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 1L, 1L, 1L), 4L, 
          1L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(15L, 19L, 87L, 44L, 15L, 48L, 21L, 85L, 90L, 30L, 88L, 95L, 48L, 92L, 29L, 52L, 46L, 46L, 7L, 23L, 96L, 97L, 43L), 19L, 
          5L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-98L, -96L, -94L, -94L, -94L, -80L, -80L, -78L, -64L, -62L, -62L, -46L, -42L, -38L, -36L, -36L, -34L, -32L, -20L, -18L, -16L, -12L, -8L, -4L, -4L, -2L, -2L, 2L, 6L, 12L, 34L, 40L, 42L, 44L, 46L, 46L, 50L, 54L, 58L, 58L, 70L, 72L, 72L, 76L, 78L, 86L), 33L, 
          1L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L), 13L, 
          2L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(6L, 7L, 19L, 36L, 44L, 63L, 68L, 72L, 83L), 8L, 
          5L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-64L, 12L, 56L, 50L, 94L, 6L, 0L, 70L, -70L, 46L, -84L, -64L, 4L, 76L, 28L, 94L, -8L, 24L, 76L, 64L, -62L, -34L), 15L, 
          1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 21L, 
          2L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(71L, 57L, 20L, 8L, 90L, 69L, 15L, 62L, 45L, 14L, 65L, 20L, 48L, 9L), 10L, 
          3L
      )))
  
  }
  
  main()
source_py: def longest_increasing_odd_even_subsequence(arr, n):
      lioes = list()
      maxLen = 0
      for i in range(n):
          lioes.append(1)
      i = 1
      for i in range(n):
          for j in range(i):
              if ((arr[i] > arr[j]) and (((arr[i] + arr[j]) % 2) != 0) and (lioes[i] < (lioes[j] + 1))):
                  lioes[i] = (lioes[j] + 1)
      for i in range(n):
          if (maxLen < lioes[i]):
              maxLen = lioes[i]
      return maxLen
source_cpp: int longest_increasing_odd_even_subsequence(vector<int> arr, int n) {
    int lioes [ n ];
    int maxLen = 0;
    for ( int i = 0;
    i < n;
    i ++ ) lioes [ i ] = 1;
    for ( int i = 1;
    i < n;
    i ++ ) for ( int j = 0;
    j < i;
    j ++ ) if ( arr [ i ] > arr [ j ] && ( arr [ i ] + arr [ j ] ) % 2 != 0 && lioes [ i ] < lioes [ j ] + 1 ) lioes [ i ] = lioes [ j ] + 1;
    for ( int i = 0;
    i < n;
    i ++ ) if ( maxLen < lioes [ i ] ) maxLen = lioes [ i ];
    return maxLen;
  }