title: Minimum Number Platforms Required Railwaybus Station
signature: func minimumNumberPlatformsRequiredRailwaybusStation(arr []int, dep []int, n int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(arr []int, dep []int, n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(arr, dep, n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver([]int{8, 24, 28, 64, 75, 86, 93, 95}, 
  	[]int{19, 30, 41, 51, 62, 68, 85, 96}, 
  	6, 2)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver([]int{-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}, 
  	[]int{-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)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver([]int{0, 0, 0, 0, 0, 0, 1}, 
  	[]int{0, 0, 0, 0, 0, 1, 1}, 
  	6, 1)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver([]int{2, 4, 5, 5, 21, 35, 48, 50, 51, 59, 61, 64, 71, 76, 81, 95}, 
  	[]int{5, 8, 28, 31, 40, 40, 43, 47, 49, 50, 51, 67, 67, 84, 86, 90}, 
  	8, 3)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver([]int{-64, -52, 44, 52, 90}, 
  	[]int{-62, -16, 22, 26, 58}, 
  	3, 1)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver([]int{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}, 
  	[]int{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)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver([]int{2, 15, 25, 55, 72, 96, 98}, 
  	[]int{3, 6, 11, 19, 26, 37, 39}, 
  	6, 1)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver([]int{-98, -76, -72, -60, -58, -56, -56, -48, -40, -34, -34, -30, -24, -20, 4, 8, 30, 30, 40, 52, 74, 74, 76}, 
  	[]int{-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)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver([]int{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}, 
  	[]int{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)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver([]int{1, 20, 34, 37, 56, 72, 84, 87}, 
  	[]int{15, 29, 54, 62, 68, 70, 84, 96}, 
  	6, 2)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
  }