title: Minimum Number Platforms Required Railwaybus Station
signature: int minimumNumberPlatformsRequiredRailwaybusStation(vector<int> arr, vector<int> dep, int n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(vector<int> arr, vector<int> dep, int n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, dep, n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver({8, 24, 28, 64, 75, 86, 93, 95}, {19, 30, 41, 51, 62, 68, 85, 96}, 6, 2); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      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); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver({0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 1, 1}, 6, 1); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      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); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver({-64, -52, 44, 52, 90}, {-62, -16, 22, 26, 58}, 3, 1); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      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); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver({2, 15, 25, 55, 72, 96, 98}, {3, 6, 11, 19, 26, 37, 39}, 6, 1); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      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); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      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); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver({1, 20, 34, 37, 56, 72, 84, 87}, {15, 29, 54, 62, 68, 70, 84, 96}, 6, 2); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
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;
  }