• + 0 comments

    Pyton 3:

    def serviceLane(n, cases):
        return [min(width[c[0]:c[1]+1]) for c in cases]
    

    Nice:

    1. Description is completely confused about width and indices, also explains 1-based indexing, input uses 0-based. Prepares you for real world clients, that invariably will want the opposite of what they are actually telling you :-)

    2. In python framework, width is not part of the function signature, but can be looked up in the namespace of the calling context. Teaches you about tight coupling as an important skill of writing code in a way, to secure your job.