• + 0 comments

    amazing!!

    Python implimentation of this logic:

    def optimised(n, queries):
        intial = []
        _max = 0
        x = 0
        
        for _ in range(1, n+1):
            intial.append(0)
            
        for query in queries:
            intial[query[0]] += query[2]
            if query[1]+1 <= len(intial) - 1: intial[query[1]+1] -= query[2]
        
        for i in intial:
            x += i
            _max = max(x, _max)
        return _max