title: Minimum Number Platforms Required Railwaybus Station
signature: function minimum_number_platforms_required_railwaybus_station(arr, dep, n)
test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, dep, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, dep, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({8, 24, 28, 64, 75, 86, 93, 95}, {19, 30, 41, 51, 62, 68, 85, 96}, 6, 2)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-94, -92, -86, -78, -68, -58, -54, -42, -30, -30, -28, -26, -18, -8, -6, -4, 0, 0, 2, 6, 8, 14, 16, 30, 34, 50, 58, 58, 66, 78, 84, 86, 94, 98}, {-98, -90, -84, -76, -64, -62, -52, -48, -44, -34, -24, -22, -12, -10, -8, -4, 10, 10, 14, 16, 22, 28, 28, 34, 40, 46, 50, 50, 52, 64, 68, 78, 80, 96}, 18, 2)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 1, 1}, 6, 1)
      print(string.format("TEST-2...%s",result))
  
      result = driver({2, 4, 5, 5, 21, 35, 48, 50, 51, 59, 61, 64, 71, 76, 81, 95}, {5, 8, 28, 31, 40, 40, 43, 47, 49, 50, 51, 67, 67, 84, 86, 90}, 8, 3)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-64, -52, 44, 52, 90}, {-62, -16, 22, 26, 58}, 3, 1)
      print(string.format("TEST-4...%s",result))
  
      result = driver({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}, {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}, 17, 1)
      print(string.format("TEST-5...%s",result))
  
      result = driver({2, 15, 25, 55, 72, 96, 98}, {3, 6, 11, 19, 26, 37, 39}, 6, 1)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-98, -76, -72, -60, -58, -56, -56, -48, -40, -34, -34, -30, -24, -20, 4, 8, 30, 30, 40, 52, 74, 74, 76}, {-98, -96, -82, -76, -76, -72, -66, -64, -50, -40, -28, -22, -20, -8, 6, 8, 14, 18, 34, 36, 52, 52, 56}, 20, 2)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 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}, {0, 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}, 22, 1)
      print(string.format("TEST-8...%s",result))
  
      result = driver({1, 20, 34, 37, 56, 72, 84, 87}, {15, 29, 54, 62, 68, 70, 84, 96}, 6, 2)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def minimum_number_platforms_required_railwaybus_station(arr, dep, n):
      arr.sort()
      dep.sort()
      plat_needed = 1
      result = 1
      i = 1
      j = 0
      while ((i < n) and (j < n)):
          if (arr[i] < dep[j]):
              plat_needed += 1
              i += 1
              if (plat_needed > result):
                  result = plat_needed
          else:
              plat_needed -= 1
              j += 1
      return result
source_cpp: int minimum_number_platforms_required_railwaybus_station(vector<int> arr, vector<int> dep, int n) {
    sort(arr.begin(), arr.end());
    sort(dep.begin(), dep.end());
    int plat_needed = 1, result = 1;
    int i = 1, j = 0;
    while ( i < n && j < n ) {
      if ( arr [ i ] <= dep [ j ] ) {
        plat_needed ++;
        i ++;
        if ( plat_needed > result ) result = plat_needed;
      }
      else {
        plat_needed --;
        j ++;
      }
    }
    return result;
  }