Untitled

 avatar
unknown
python
a year ago
741 B
4
Indexable
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 ""
Editor is loading...
Leave a Comment