Racket skip list solution
Find overlapping intervals, remove and merge them with new left and right.\nFinally, insert new left and right.\n\nThere are two ordered dict implementation in 
Find overlapping intervals, remove and merge them with new `left` and `right`.\nFinally, insert new `left` and `right`.\n\nThere are two ordered dict implementation in Racket: splay-tree and skip-list.\nsplay-tree can\'t pass on Leetcode while skip-list can.\n\n```scheme\n(require data/skip-list)\n\n(define count-intervals%\n  (class object%\n    (super-new)\n\n    (init-field [m (make-skip-list)]\n                [cnt 0])\n\n    (define (len lower upper)\n      (- upper lower -1))\n\n    (define/public (add left right)\n      (let loop ([pos (dict-iterate-least/>=? m left)])\n        (when pos\n          (let ([lower (dict-iterate-value m pos)]\n                [upper (dict-iterate-key m pos)])\n            (when (<= lower right)\n              (set! left (min left lower))\n              (set! right (max right upper))\n              (set! cnt (- cnt (len lower upper))) \n\n              (dict-remove! m upper)\n              (loop (dict-iterate-next m pos))))))\n\n      (set! cnt (+ cnt (len left right)))\n      (dict-set! m right left))\n\n    (define/public (count)\n      cnt)))\n```
['Racket']