Untitled

mail@pastecode.io avatar
unknown
python
a month ago
741 B
1
Indexable
Never
def solution(stationsA, stationsB, stationsC, origin, destination):
    o, d = ' ', ' '

    for station in stationsA:
        if origin == station:
            o = 'A'
        if destination == station:
            d = 'A'

    for station in stationsB:
        if origin == station:
            o = 'B'
        if destination == station:
            d = 'B'

    for station in stationsC:
        if origin == station:
            o = 'C'
        if destination == station:
            d = 'C'

    if d == ' ' or o == ' ':
        return ""

    if o == 'A' and d == 'B':
        return "AB"
    if o == 'A' and d == 'C':
        return "ABC"
    if o == 'B' and d == 'C':
        return "BC"

    return ""
Leave a Comment