title: Minimum Number Platforms Required Railwaybus Station
signature: class Solution {
  
      public Integer minimumNumberPlatformsRequiredRailwaybusStation(ArrayList<Integer> arr, ArrayList<Integer> dep, Integer n) {
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;
  }
question_info.extension: java
question_info.entry_fn_name: minimumNumberPlatformsRequiredRailwaybusStation
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 2, "inputs": {"arr": [8, 24, 28, 64, 75, 86, 93, 95], "dep": [19, 30, 41, 51, 62, 68, 85, 96], "n": 6}}, {"idx": 1, "outputs": 2, "inputs": {"arr": [-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], "dep": [-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], "n": 18}}, {"idx": 2, "outputs": 1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 1], "dep": [0, 0, 0, 0, 0, 1, 1], "n": 6}}, {"idx": 3, "outputs": 3, "inputs": {"arr": [2, 4, 5, 5, 21, 35, 48, 50, 51, 59, 61, 64, 71, 76, 81, 95], "dep": [5, 8, 28, 31, 40, 40, 43, 47, 49, 50, 51, 67, 67, 84, 86, 90], "n": 8}}, {"idx": 4, "outputs": 1, "inputs": {"arr": [-64, -52, 44, 52, 90], "dep": [-62, -16, 22, 26, 58], "n": 3}}, {"idx": 5, "outputs": 1, "inputs": {"arr": [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], "dep": [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], "n": 17}}, {"idx": 6, "outputs": 1, "inputs": {"arr": [2, 15, 25, 55, 72, 96, 98], "dep": [3, 6, 11, 19, 26, 37, 39], "n": 6}}, {"idx": 7, "outputs": 2, "inputs": {"arr": [-98, -76, -72, -60, -58, -56, -56, -48, -40, -34, -34, -30, -24, -20, 4, 8, 30, 30, 40, 52, 74, 74, 76], "dep": [-98, -96, -82, -76, -76, -72, -66, -64, -50, -40, -28, -22, -20, -8, 6, 8, 14, 18, 34, 36, 52, 52, 56], "n": 20}}, {"idx": 8, "outputs": 1, "inputs": {"arr": [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], "dep": [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], "n": 22}}, {"idx": 9, "outputs": 2, "inputs": {"arr": [1, 20, 34, 37, 56, 72, 84, 87], "dep": [15, 29, 54, 62, 68, 70, 84, 96], "n": 6}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> arr, ArrayList<Integer> dep, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(arr, dep, n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(8, 24, 28, 64, 75, 86, 93, 95)), new ArrayList<>(Arrays.asList(19, 30, 41, 51, 62, 68, 85, 96)), 6, 2);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-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)), new ArrayList<>(Arrays.asList(-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);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 1)), new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 1, 1)), 6, 1);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 4, 5, 5, 21, 35, 48, 50, 51, 59, 61, 64, 71, 76, 81, 95)), new ArrayList<>(Arrays.asList(5, 8, 28, 31, 40, 40, 43, 47, 49, 50, 51, 67, 67, 84, 86, 90)), 8, 3);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-64, -52, 44, 52, 90)), new ArrayList<>(Arrays.asList(-62, -16, 22, 26, 58)), 3, 1);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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)), new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(2, 15, 25, 55, 72, 96, 98)), new ArrayList<>(Arrays.asList(3, 6, 11, 19, 26, 37, 39)), 6, 1);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-98, -76, -72, -60, -58, -56, -56, -48, -40, -34, -34, -30, -24, -20, 4, 8, 30, 30, 40, 52, 74, 74, 76)), new ArrayList<>(Arrays.asList(-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);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(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)), new ArrayList<>(Arrays.asList(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);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 20, 34, 37, 56, 72, 84, 87)), new ArrayList<>(Arrays.asList(15, 29, 54, 62, 68, 70, 84, 96)), 6, 2);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> arr, ArrayList<Integer> dep, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(arr, dep, n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__