Equal Stacks

  • + 0 comments

    Python3 set intersect:

    def equalStacks(h1, h2, h3):
        s1 = set(accumulate(reversed(h1), lambda s, n: s + n))
        s2 = set(accumulate(reversed(h2), lambda s, n: s + n))
        s3 = set(accumulate(reversed(h3), lambda s, n: s + n))
        
        return max(s1 & s2 & s3, default=0)