python list
similiar to 715\n```\nclass CountIntervals:\n\n    def init(self):\n        self.arr = []\n        self.cnt = 0\n\n    def add(self, left: int, right: int) -> N
similiar to 715\n```\nclass CountIntervals:\n\n    def __init__(self):\n        self.arr = []\n        self.cnt = 0\n\n    def add(self, left: int, right: int) -> None:\n        pos = bisect_left(self.arr, (left, right))\n        if pos > 0: pos-=1\n        while pos<len(self.arr):\n            if left>self.arr[pos][1]:\n                pos+=1\n                continue\n            if self.arr[pos][0]>right: break\n            left = min(left, self.arr[pos][0])\n            right = max(right, self.arr[pos][1])\n            removed = self.arr.pop(pos)\n            self.cnt-=removed[1]-removed[0]+1\n        self.arr.insert(pos, (left, right))  \n        self.cnt+=right-left+1\n\n    def count(self) -> int:\n        return self.cnt\n        \n\n
[]