[Question]
  [
## Challenge
Given daily arrival and departure times of every train that reaches a railway station, find the minimum number of platforms required for the railway station so that no train waits.
In other words, find the maximal number of trains simultaneously present in the station.
## Input
* a pair of lists of times: arrivals and departures; the two lists have same length; arrival `i` corresponds to the same train as departure `i`.
* **alternatively**, a list of pairs of times, or any equivalent.
* times are numbers between `0`, included, and `24`, excluded.
* there are no dates, only times: input is the daily schedule and repeats every day.
* the departure time of a train **can** be lower than its arrival time; in that case, the train is understood to arrive on a day and depart on the next day; that train will require a platform before midnight and after midnight.
* if the arrival time is lower than the departure time, the train is understood to arrive and depart on the same day.
* input can be restricted to integers
## Output
* one integer, the minimum required number of platforms.
## Test cases
```
arrivals   = [10, 13, 16]
departures = [12, 15, 18]
out = 1
arrivals   = [10, 11]
departures = [12, 13]
out = 2
arrivals   = [ 1, 3, 7, 9,10,10,19,23]
departures = [11, 4,11,10,11, 2, 2, 2]
out = 5
arrivals   = [1, 2]
departures = [2, 3]
out = 2
arrivals   = [1, 2]
departures = [3, 2]
out = 2
arrivals   = [2, 22]
departures = [5,  6]
out = 2
```
## Rules
* This is code-golf, the shortest code in bytes wins!
## Related challenges
* [Count the timespans](https://codegolf.stackexchange.com/questions/166802/count-the-timespans)
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 19 bytes
```
1ị>×24+)r/€%24ċþF§Ṁ
```
[Try it online!](https://tio.run/##y0rNyan8/9/w4e5uu8PTjUy0NYv0HzWtUTUyOdJ9eJ/boeUPdzb8P9wOFDo66eHOGf//R3NxRkcbGugoGBrF6ihEGxoDWaZglhmQZREbq4OmwBDIMoYJA9mGIFGgLhMQbQ4TsAQyDMDqDWBCIBbECEsow8gYxIAbBRHTUYCZDmSCXWIEZgDFYgE "Jelly – Try It Online")
## How it works
If you expand the times out and lay them out as a visual aid you get something like this (3rd test case as an example):
```
1 2 3 4 5 6 7 8 9 10 11                                       1 2
    3 4     7 8 9 10 11                      19 20 21 22 23 0 1 2
                9 10                                     23 0 1 2 
                  10 11
                  10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 1 2
```
(Note that the `1 2` in the top right is the continuation into the next day)
From this, it's clear that the number of platforms required is equal to the maximum of the number of repeated occurrences of each time. For example, 10 appears in the ranges 5 times in this example (the maximum), so the output is 5. The only problem is with times spanning multiple days, which we fix by adding 24 to those values.
The code works as follows (out of date):
```
1ị>×24+)r/€%24ċþF§Ṁ - Main link, takes a list of pairs of times
       )            - Over each pair, map:
1ị                  -   Is the first element...
  >                 -   ...greater than each element?
                    -   This yields [0, 0] for increasing pairs and [0, 1] for decreasing
   ×24              -   Multiply each one by 24
      +             -   Add in to the original pair
                    - This replaces a pair [a, b] with [a, b+24] if b < a
          €         - Over each pair, map:
        r/          -   Convert to a range
           %24      - Modulo all values by 24
                F   - Flatten this list of pairs to get all times a train is at the station
               þ    - Pair each time up with each range, then, over the pairs:
              ċ     - Count how many times the time is in that range (either 1 or 0)
                 §  - Take the sum of all lists, giving the number of times a train is at the station for each time
                  Ṁ - Take the maximum of these sums
```
[Answer]
# [Python](https://docs.python.org/2/), 62 bytes
```
lambda l:max(sum(a-b^b-h^h-a<1for a,b in l)for h in range(24))
```
[Try it online!](https://tio.run/##dZDhbsIgFIX/8xQ3/oIEl9Gqm814ElcNtXRtRiuhdOpevruojZvtEiCXy3fOPcGefXloor6Q771RdZYrMEmtTrTtaqrm2Tabl9tyrt5EcXCgeAZVA4aFSxlKp5oPTaMFY32uC3Ba5ZQlTvvONaC/lKFOHXdVYztP2VNrTeXpTM7YRqSMkGNZGQ0iIeDdGU9QzlUoajnk2iqHLhprfbJ673UOEjbXCRAC7O4BYpYSxPba@gQyZD4JGMS/K0unPBkBgmHbznikCmqwYV3V@FtTymEmv3X6wQYgxBDPHESMe5WSu@3lJcLuEvdrSg5dsBdkQismdfGgiR40IDjguBcOa476sNY8ikcmiC04ngHAOrquwXX5mOTy9tcC@X9TTPHxL/9HPsweCfBvYDVWyDEtA3tFZfQD "Python 2 – Try It Online")
Golfing [Surculose Sputum's solution](https://codegolf.stackexchange.com/a/210846/20260). The new part is `a-b^b-h^h-a<1` to check whether the time `h` lies in the interval from `a` to `b` taken cyclically, that is, their sorted ordering is a cyclic permutation of `[a,h,b]`. To do this, we check whether an odd number of the differences `a-b`, `b-h`,`h-a` are negative. I first did this with multiplication `(a-b)^(b-h)^(h-a)<1`. But, xor (`^`) lets us do the same and cuts parens with better precedence.
[Answer]
# [R](https://www.r-project.org/), 111 bytes
Brute force - unfortunately TIO can't run it but R 4.0.2 on desktop doesn't have stack issues.
```
{f=pryr::f
`:`=f(a,b,`if`(a<b,a:b,c(a:24,0:b)))
f(a,d,max(sapply(0:24,f(x,sum(mapply(f(u,v,x%in%u:v),a,d))))))}
```
[Try it online!](https://tio.run/##dY7RCoMwDEXf/Yq@DFLIg22dm2X@S6ujINhN6hRl7NtdqrDBZCUJIffcpGHpWvtw9@D7cnm6sgtz0NolRpvSgcUKTeMM2EuFVldYg9Uyw1RXnPMkAlf0doLedl07QxpFBxP2gwe/zRwMOOJ0aG6HQY8cycLX9/qehhpEikwoypzTFSGpO1Ke6cwOEx9E/crIaMcJWYFExihQqhUnKUOqcUi93GLvl5EmSf2R1N4VF60a/ZjlnC9v "R – Try It Online")
Much shorter version with simpler logic:
# [R](https://www.r-project.org/), 72 bytes
```
function(a,d)max(sapply(0:24,function(x)sum(a<=x&x<=d|a>d&(x>=a|x<=d))))
```
[Try it online!](https://tio.run/##dY/RCoMwDEXf9xV9khTyoK1zc1j/JSjCwGqxCh347y514GCykoSk5@bSTpvrae7GyXqzdcvQzM9xAMJWWgrgybn@BelD5XjAIP1igSoTklCZdqW6TSDUhtY4Sj5fT2ggS1FkmrOQyJPi7sp5l/JykmWHRP9iFOxxQ1EiK2OUqPQuZ5Qj13jJvfrEeV9FNSP9B@nzVjTaGb9YFPyxNw "R – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 73 bytes
```
lambda l:max(sum([a<=h<=b,not b<h<a][a>b]for a,b in l)for h in range(24))
```
[Try it online!](https://tio.run/##dZDhboMgFIX/8xQ3/QUJWaa23WpkL@JMgxWnGSpBXNu9vLu0Nd2qS4BcLt859wRzdlXXhmMp3kctm7yQoONGnmg/NDSViagSkfO2c5AnVSKzVL7lWdlZkDyHugXN/KXypZXth6LhmrGxUCVYJQvKYqvcYFtQX1JTK4/7ujWDo@ypN7p2dCVWLA0yRsixqrWCICbg7BlPkNbWKOo5FMpIiy4Ka3Uy6uBUAQLS6wTwAfb3ABHLCGIHZVwMOTKfBDTi37WhS56MAMGw/aAdUiXV2DC2bt2tKcQ0k98642QD4GMEzxyCCPc2I3fby0uI3Q3u14x0g7cPyII2WNRFkyZ80EDAAce9cNhx1Pu142E0M0FszfH0ANbhdU2um8ckl7e/Fsj/m2KJj375P/J@9kyAfwPbuULMaeHZKyrCHw "Python 2 – Try It Online")
Input: A list of pairs of time.
For each hour in the day, check how many trains are in the station. Then find the max of those.
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~19~~ 17 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
εD¬‹24*+Ÿ24%}˜D¢à
```
-2 bytes by taking inspiration from the [*@cairdCoinheringaahing*'s Jelly answer](https://codegolf.stackexchange.com/a/210818/52210) for the first part (`D¬‹24*+`), so make sure to upvote him as well.
Input as a list of pairs of times.
[Try it online](https://tio.run/##MzBNTDJM/f//3FaXQ2seNew0MtHSPrrDyES19vQcl0OLDi/4/z862lDH0DBWJ9pYxwRImkM4ljqGBkDK0ADCBdJGIMoSTBkZA6lYAA) or [verify all test cases](https://tio.run/##MzBNTDJM/V9Waa@k8KhtkoKSfeX/c1tdDq151LDTyERL@@gOIxPV2tNzXA4tOrzgv87/6OhoQwMdQ6NYnWhDYx1DUxBtpmNoERuro4AkZahjaAwV0jE0BIoY65gASXMIx1LH0ACkygDCBdJgTZZgysgYSEG1gvk6cJOMwVyorJEOyHIjIx2z2NhYAA).
**Explanation:**
```
ε             # Map each pair of the (implicit) input-list to:
 D            #  Duplicate the current pair
  ¬           #  Push the first value of the pair (without popping)
   ‹          #  Check for both whether this value is larger (1 if truthy; 0 if falsey)
    24*       #  Multiply both by 24
       +      #  Add it to the pair we duplicated (at the same positions)
        Ÿ     #  Pop the pair and push a list of integers in that inclusive range
         24%  #  Take modulo-24 on each value
}˜            # After the map: flatten the list of lists of integers
  D           # Duplicate the list
   ¢          # Count how many times each value occurs in the list
    à         # Pop and push the maximum
              # (after which it is output implicitly as result)
```
Uses the legacy version of 05AB1E, where `[2,2]` with builtin `Ÿ` would result in `[2]` (as expected) instead of `[2,2]`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
>/×24+Ṫr%24FĠẈṀ
```
A monadic Link accepting a list of lists, `[arrivals, departures]`, which yields the number of platforms.
**[Try it online!](https://tio.run/##y0rNyan8/99O//B0IxPthztXFakambgdWfBwV8fDnQ3/D7c/alrz/380l0J0tKGBjoKhMRCbxXIp6EQbGgGZpkBsERvLpQOVNkRIGUOEFQx1FICaFMyB2BIobADFQLaRMUQ1UIUJSC9UBkgrGMEw1GygYrBaoJgxmpCxDkwVUNIIIgZ0loIZUDAWAA "Jelly – Try It Online")**
### How?
```
>/×24+Ṫr%24FĠẈṀ - Link: [arrivals, departures] = X
 /              - reduce by
>               -   greater than?
  ×24           - multiply by 24
      Ṫ         - tail (this actually removes the departures from X and yields them,
                        leaving [arivals] as our left argument for the rest of the chain.)
     +          - add (adds 24 to the departures that should be on the next day)
       r        - inclusive range (vectorises)
        %24     - modulo 24 (change to 24 hour times)
           F    - flatten (gets a list of all hours trains are demanding to be at the station)
            Ġ   - group indices by their values
             Ẉ  - length of each (number of trains at the station at each of the utilised hours)
              Ṁ - maximum
```
---
Also 15 as a dyadic Link accepting `arrivals` on the left and `departures` on the right:
```
>×24+⁹r⁸%24FĠẈṀ
```
[Try it online!](https://tio.run/##y0rNyan8/9/u8HQjE@1HjTuLHjXuUDUycTuy4OGujoc7G/4fXq7/qGnN///RXArR0YYGOgqGxkBsFsuloBNtaARkmgKxRWwslw5U2hAhZQwRVjDUUQBqUjAHYkugsAEUA9lGxhDVQBUmIL1QGSCtYATDULOBisFqgWLGaELGOjBVQEkjiBjQWQpmQMFYAA "Jelly – Try It Online")
[Answer]
# x86-16 machine code, ~~40~~ 39 bytes
```
00000000: b217 32db 5156 32f6 ad3a c412 f63a e212  ..2.QV2..:...:..
00000010: f63a d012 f67a 0143 e2ec 3afb 7f02 8afb  .:...z.C..:.....
00000020: 5e59 feca 79dc c3                        ^Y..y..
```
**Listing:**
```
B2 17       MOV  DL, 23             ; loop 23 to 0 hours (h)
        HOUR_LOOP:
32 DB       XOR  BL, BL             ; reset max hour
51          PUSH CX                 ; save array length 
56          PUSH SI                 ; save array pointer 
        TRAIN_LOOP: 
32 F6       XOR  DH, DH             ; clear negatives counter 
AD          LODSW                   ; AL = arrival (a), AH = departure (b) 
3A C4       CMP  AL, AH             ; is a-b negative? 
12 F6       ADC  DH, DH             ; if so, bit-shift 1 into DH 
3A E2       CMP  AH, DL             ; is b-h negative? 
12 F6       ADC  DH, DH             ; if so, bit-shift another 1 
3A D0       CMP  DL, AL             ; is h-a negative? 
12 F6       ADC  DH, DH             ; if so, bit-shift another 1 
7A 01       JP   NOT_AT_STATION     ; was there an odd number of negatives? 
43          INC  BX                 ; if so, increment count of trains at station 
        NOT_AT_STATION: 
E2 EC       LOOP TRAIN_LOOP         ; go to next train 
3A FB       CMP  BH, BL             ; BH = max( BL, BH ) 
7F 02       JG   NOT_MORE           ; if not highest number of trains, continue 
8A FB       MOV  BH, BL             ; BH set to new max 
        NOT_MORE:    
5E          POP  SI                 ; restore array 
59          POP  CX                 ; restore array length 
FE CA       DEC  DL                 ; decrement hour 
79 DC       JNS  HOUR_LOOP          ; if not past zero hour, keep looping 
C3          RET                     ; return to caller
```
[Try it online!](https://tio.run/##pVZtb9s2EP4c/YpDg6EpwBiRnbcaGAYnzuoEThzE7lagCwJKoi1tMimQVOKs6G/P7kjJkpMV8DADsSzec889vBcy3BixjPLn/UUcv3QyaUX@YJ6l5SuQqtBinq2CjlhZoSUUGu3zoJNwy4OCG9MH6BiLqwt491MCt4Pp9A/5LpjzLH9l@nVwOSZTxyJX0FnkKsphyTMZ0Fc/APzkggNokzH4aoWx4f3OLuhSgk0F8Eg9ChDZIrVARuM8Yp7n7jXmRvwbR/d@O1xvS9zhlrijLXHHW@JOtsSd/ginhQ3qBZ/tldIAgq8YfVGmhREWvxeZwWIbiIR9EkI6GkdoWm4RuUWr1kpMK3F7JaGVxK/kKjFPsINheAo/AzUQcK35M5jsb8GA57gqVoWIrUhISplb51iUJgWNAtHVcGqBTRDMMVbOUbGDL9Uj7j5nFAY94vxtsCZBs7vB5c0U6s@uX52XMraZkm@T5BkF1/TydqONtdq0E5OgmMiJSUhMa2u@dAmVjgbm3mtIxJzTvqyC97T8HvwU@WyoAupsxOkPUhYvCx8Wk0phlTB1spbcolvt9IuD/ykF@Ml@8Cj0yeZgFMMQXC6Ek0LTviGlpZ5slXp/QlQ4qg1GDNrk/SYzrmt1slqnvxKJ4dDkCqtKW5S25UKVOGgq6MNRNvyvPfiKku6ZI/iwbvzquPH1fvEPL@R68hvAcMyg23PdGatSooJUq3KRQvcQUlVqE4wmn@8expPJrff6MrkDOEOvs7Hz8qOzxA4huIPcfp6O4PwLmuvG9R2YC7mwaQOZXr6BFIpOYR04na@jDkcM/7xW12xSLLjNHrHGTns1B@PJcPq7Zx6MsU@QOXvEftjjHxgMRjQVouDallrAXuQzdX59C4h2dnLMDPD9aB3Ad8tgeL4houqUKLMmzeYWQlASCzgctSgJPa4po/30P1JyqfAG0BA2lFSxwZoy3ef/i/IKGeFmMnsYzB6ms8HscnJDg/PEDV09mCEuQSUJyHIZoZOaN0n34S5vMNxZVewqFkcHTIRvKHSxGu85zKjF4eDufNmM2K/qNrmFpvBO/EIRkcR705M0aTgbrVvwjGqKHbjn@3JUdf/Vp2pr15O7izoVuHlI8Salg73ZkxeIQ48FzGQpmvnYDEOt7vQ8UbygJu/v@KZG0eumxrmwSld93ZjrsdgwtydjeEHlG3tUImItlgKzuB6uKzq11zPZ2haDv4Qo8LZRRX1O3V3M6mjY7dLVBI8OoV/8vzHBrr/h6KUP3/wZ9J3BN3dteFHr14JnGlPU6XS@B@46DfvQiZ6tgJBBj0F4wMIuPnosPMLHMQtPHaxbw9DYbWAhC3vO3ntlZ@7pbYevbT16dp3tqLZhtFOyhU7HIYMT9/Mjw1AuXOge5P/RkfcqhuNN9i5Dpm6XHTvjSWt3aET/0Fm7Xtnppi@aMRhCDoKXfwA "Assembly (gcc, x64, Linux) – Try It Online")
As a callable function. Input array as a list of pairs at `SI`, length in `CX` result in `BH`.
**Explanation:**
Loops through 24 hours and checks, for each hour, how many trains will be at the station.
Uses [@xnor's formula](https://codegolf.stackexchange.com/a/210863/84624) to check cyclical time interval -- that is if `a-b`, `b-h` and `h-a` are an odd number of negative results then `h` falls within the interval. Each of these are compared and if negative the carry flag (`CF`) is set and bit-shifted as a `1` or `0` into `DH` to record the number of negative results.
The parity flag (`PF`) is then checked, which is set if the number of `1` bits is even. If odd, a counter is incremented for that hour and then compared to the previous highest counter and the max is updated for the result.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 20 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?") ([SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set"))
Anonymous tacit infix function taking arrivals as left argument and departures as right argument.
```
{≢⍉⊢⌸∊⍵}24|⊣…¨⊢+24×>
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/v/pR56JHvZ2PuhY96tnxqKPrUe/WWiOTmkddix81LDu0AiiubWRyeLrd/7RHbRMe9fY96mp@1LvmUe@WQ@uNH7VNfNQ3NTjIGUiGeHgG/zc0UDA0VjA0U0hTMDRSMDRVMLRQwAEe9c5VMOQCaTCEqjZWwAtAGoy4DBWMFcwVLBVAGoHIUsHIGKTdUMEERECMMwJDsAZTLhA3DYgJmI5sA0iDMcgEojQAAA "APL (Dyalog Extended) – Try It Online")
`>` 1 if arrival is after departure
`24×` multiply 24 by that
`⊢+` add the right argument (the departure) to that
`⊢…¨` inclusive range for each arrival-departure pair
`24|` division remainder when divided by 24
`{`…`}` apply the following lambda (`⍵` is the argument, i.e. the list of ranges)
 `∊⍵` **ϵ**nlist (flatten) the argument
 `⊢⌸` table of indices for each unique hour
 `⍉` transpose (so rows, representing how many of each hour there are, become columns)
 `≢` count the number of rows (i.e. the maximum number of occurrences of any hour)
[Answer]
# JavaScript (ES6), 75 bytes
Expects a list of pairs of times.
```
a=>(t=24,g=m=>t--?g(a.map(([a,d])=>n+=(t<a)+(t>d)<=(a>d),n=0)|n<m?m:n):m)``
```
[Try it online!](https://tio.run/##fY3LDoIwEEX3fgXLaSikBXxAGPiQhoQGkGhoS6Rx5b9jAdmpqzm5c@bOXT7l1Dxuow20abv5irPEAixGCe1RYWGDoOxBhkqOAELStiJYaB/B5pL4YIuW5AjSDaqRkZfOVakyTTJF6npujJ7M0IWD6eEKQnBGPR5V1BM8dnRc6eToUlWEHP7o3FH8XXIbvjiuMVnmeQ9SB2y9Znu00FaYfiCKF/hRvBnUWz/Pbw "JavaScript (Node.js) – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 42 35 33 bytes
```
[:>./[:+/(([:~:/1#~[,:]+>*[)>:)"0
```
[Try it online!](https://tio.run/##ZYvLCsIwEEX3/YpLhD5MbTKJrw60iIIrceE2diUWceMHCP31mj4WxcLMMJx77rsVWVSjYERIocF@VxlOt8u5dVxmyrFUcey4YUWLxqVcyXLpkpITodskuB4zzD2hG7h0Yo6eVL0gzCKkHsWl8q@Qh2@V@vSeCEL1L8@kA8tQgwQFwfPx@mCDAgRYYAfkIN1PDmNRg3yy7m7H/G@GGZqma/bciwZkB0wjtqDtmGxA@0nH39qvDdof "J – Try It Online")
### High level idea:
1. Represent each range with a 0-1 list, one slot for each hour, a `1` meaning that hour is occupied.
2. Sum the rows.
3. Take the max.
### Example
Take `1 2 23 f 5 4 2`, that is, the ranges:
```
1 5
2 4
23 2
```
We apply `(([:~:/1#~[,:]+>*[)>:)"0` (mostly J mechanics) to create the 0-1 lists:
```
0 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 0 1 1 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
```
Note how the `23 2` range extends as needed to go into the next day. This is accomplished by `]+>*[` which adds to the right arg `]+` the left arg `[` times `*` "1 if the right arg is less than the let" `>`.
Next we do the row-wise sum:
```
0 1 2 2 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
```
And take the max:
```
2
```
### Bonus, 34 byte version using Adam's APL approach
```
[:>./[:#/.~@;([<@-.~&i.1+]+24*>)"0
```
[Try it online!](https://tio.run/##TYvBDoIwEETv/YoJJiIihW1BpQohMeHkyWvjydioF/@AX69bysFkZrJ5s/PxiUwdOoMUO1Qw7ELicruO3ppeltasSjkNp409D4Wc1m9J@T1X9bbPkspnQjwfry8adCBAAwegBVWzWigNB@KmDhkY3yoqLlVYzpwfFUhHTAvWoP3SNKDj34bTsbXwPw "J – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 24 bytes
```
Ｆ⮌θＦ⊕﹪⁻⊟ηι²⁴⊞υ⁺ικＩ⌈Ｅυ№υι
```
[Try it online!](https://tio.run/##JYzLCoMwEEX3/YpZTmAK9QFFXLrqQgjdiougKYbGxCZG@vdpYoc7D@65zLQIN1mhY3xZB/iUh3Re4ocxOI2HmZxcpdnljL2dg7bYKxM8crvhwghU6rJmKc@DXzAQcJ2wIngz1l64U2bHTvgde/FVa1jT3nKssyGRkD/kamMcBigIKoI7QUPF7VRDZTXSUCRSU5rZS3f51zjG66F/ "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｆ⮌θ
```
Loop through the arrival times in reverse order, as it's easier to process the departure times in reverse order.
```
Ｆ⊕﹪⁻⊟ηι²⁴
```
Calculate the time that this train spends at the station...
```
⊞υ⁺ικ
```
... and loop over that to push the start, intermediate and end times to the predefined empty list.
```
Ｉ⌈Ｅυ№υι
```
For each time in the list, count how many times it appears in the list, and output the maximum of those.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 117 bytes
```
\d+
$*11
(1+) (?!\1)
$&24$*
(1+) \1\b
$1
+%`^(1+) 1(1+\1)
$1 $2 1$2
1(1{24})
1
O`1+
(1+)(\s\1\b)*
$#2$*11
O^`\d+
\G\d
```
[Try it online!](https://tio.run/##JY29DsIwDIR3P4URBuVn6bmRUCdGxr6AVQVUBhYGyoZ49pCE5dPpk8/3ur8fz2sptkaSAJBD9OzOO4MnOWqS8FcGu5GA4iEvXaCyH4FFGaJUzUfT1xNozoi952xrTR9I9toH5iW3MbvYWgq4mpETnVqYGANhaLGyPpwqdGT9AQ "Retina 0.8.2 – Try It Online") Takes input as a list of pairs. Explanation:
```
\d+
$*11
```
Convert to unary, but increment all of the numbers as Retina has difficulty working with zero.
```
(1+) (?!\1)
$&24$*
```
Add 24 to all of the departure times that are less than the arrival times.
```
(1+) \1\b
$1
```
If the arrival and departure times are the same then delete one.
```
+%`^(1+) 1(1+\1)
$1 $2 1$2
```
Otherwise repeatedly fill in any times in between.
```
1(1{24})
1
```
Reduce all of the times "modulo 24" (allowing for the increment).
```
O`1+
```
Sort the times.
```
(1+)(\s\1\b)*
$#2$*11
```
Count (in unary) the number of occurrences of each times.
```
O^`\d+
```
Sort in descending order.
```
\G\d
```
Convert the first (i.e. maximum) to decimal.
[Answer]
# [Arn](https://github.com/ZippyMagician/Arn) `-fs`, [~~36~~ ~~34~~ 30 bytes](https://github.com/ZippyMagician/Arn/wiki/Carn)
```
ö·ògT£nžú#│ä♦PüâTPF™,åé@⁻BFÏc-
```
[Try it!](https://zippymagician.github.io/Arn?code=OjwoKHs+On0mJlstPjI0IDB+On1dOl98fD0+On19XCk6XzpA&input=W1sxMCAxMl0gWzEzIDE1XSBbMTYgMThdXQpbWzEwIDEyXSBbMTEgMTNdXQpbWzEgMTFdIFszIDRdIFs3IDExXSBbOSAxMF0gWzEwIDExXSBbMTAgMl0gWzE5IDJdIFsyMyAyXV0KW1sxIDNdIFsyIDJdXQ==&flags=ZWZz)
# Explained
Unpacked: `:<(({>:}&&[->24 0~:}]:_||=>:}}\):_:@`
```
:<                     Sorted in descending order
  (
    (
      {                Block with key of _
            _          Implied
          >            Is greater than
              _
            :}         Last entry
        &&             Boolean AND
            [          Begin array
                _
              ->       Exclusive range
                24     Literal twenty-four
              0        Literal zero
              ~        1-range
                  _
                :}     
            ]          End sequence
          :_           Flatten
        ||             Boolean OR
            _
          =>           Inclusive range
              _
            :}
      }                End block
      \                Map block over...
        _              ...Variable initialized to STDIN; implied
    )                  End expression
  :_
  :@                   Group based on frequency
)
                       First entry
                       Length
```
[Answer]
# [Scala](https://www.scala-lang.org/), 113 105 bytes
Saved 8 bytes thanks to the comment of @ceilingcat
---
Golfed version. [Try it online!](https://tio.run/##jY89b8IwEIZ3fsVN6CxZKLEpbSMcibFDJ9QJMbiJg1KBE2JXchvy29NLiUAdQLV88n0873uyy/Re99X7h8k8vOrSQtvnpoACdbI2x82L9VueX1KmMAJfgZiz2UHXGEClqOG7rCFns6z6tL7NtDPouGEqdUsVpmGpzMmlZoohVe40lKwb5KEHGHYdaC3qZucSWDWN/tqsfVPa3ZYl8GZLDwraCdCpqev3Fgv8xTCOOMSSYsE4jC1B5QPFE2Pstij@K5A3YQ7k/8jhmahoDMqFvBoQMx8sxym94nzvmIqLnED5L1DecRy2XUn6/uJMdpOu/wE)
```
def f(a:Seq[Int],d:Seq[Int])=(0 to 24).map(x =>(a zip d).count{case(s,e)=>s<=x&x<=e|s>e&(x>=s|x<=e)}).max
```
Ungolfed version. [Try it online!](https://tio.run/##lVA9b4MwEN35FW@KbMmKwKRpGxWkjh06VZ2qDi6QiAoMMq5Em/Db6RlIaKakEod99z7uzk2iCtX31cdnllg8q1xj7wFptkVdKLutTNkwtcGjMer77Unbd4H0b8o3oAPRIAOYD1tBrviyVDVrEcVgCj95jZQvk@qLqHskqsnAGquMFch0ygfakOMhQovFgn50G7DD4YjFruBAMo4jjEWCT1yOzjVuaZTOm9YoaSemzK45Tv1iTa53bvBXnc@T11S1hWbz2gOdBb5AEFKsucBUkpTeUNxxzi@Lg3NheFEkQP1uBe6J7U9BdxnORsRZOesJpVOO3xXm8mRDgvBfgvCKDm6KWUHPtB4Vndd5ff8L)
```
object Main {
  def platforms(a: Array[Int], d: Array[Int]): Int = {
    (0 to 24).map(x => (a zip d).count { case (start, end) => (start <= x && x <= end) || (start > end && (x >= start || x <= end)) }).max
  }
  def main(args: Array[String]): Unit = {
    println(platforms(Array(10, 13, 16), Array(12, 15, 18)))
    println(platforms(Array(10, 11), Array(12, 13)))
    println(platforms(Array(1, 3, 7, 9, 10, 10, 19, 23), Array(11, 4, 11, 10, 11, 2, 2, 2)))
    println(platforms(Array(1, 2), Array(2, 3)))
    println(platforms(Array(1, 2), Array(3, 2)))
    println(platforms(Array(2, 22), Array(5, 6)))
  }
}
```
]