<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Interval ( object ) : <EOL> def __init__ ( self , s = <NUM_LIT:0> , e = <NUM_LIT:0> ) : <EOL> self . start = s <EOL> self . end = e <EOL> class Solution ( object ) : <EOL> def merge ( self , itvls ) : <EOL> """<STR_LIT>""" <EOL> if not itvls : <EOL> return [ ] <EOL> itvls . sort ( key = lambda x : x . start ) <EOL> ret = [ itvls [ <NUM_LIT:0> ] ] <EOL> for cur in itvls [ <NUM_LIT:1> : ] : <EOL> pre = ret [ - <NUM_LIT:1> ] <EOL> if cur . start <= pre . end : <EOL> pre . end = max ( pre . end , cur . end ) <EOL> else : <EOL> ret . append ( cur ) <EOL> return ret <EOL> def merge_error ( self , itvls ) : <EOL> """<STR_LIT>""" <EOL> if not itvls : <EOL> return [ ] <EOL> ret = [ itvls [ <NUM_LIT:0> ] ] <EOL> for interval in itvls [ <NUM_LIT:1> : ] : <EOL> if ret [ - <NUM_LIT:1> ] . end < interval . start : <EOL> ret . append ( interval ) <EOL> continue <EOL> if ret [ - <NUM_LIT:1> ] . start <= interval . start <= ret [ - <NUM_LIT:1> ] . end <= interval . end : <EOL> ret [ - <NUM_LIT:1> ] . end = interval . end <EOL> continue <EOL> if interval . start <= ret [ - <NUM_LIT:1> ] . start and ret [ - <NUM_LIT:1> ] . end <= interval . end : <EOL> ret [ - <NUM_LIT:1> ] = interval <EOL> continue <EOL> if ret [ - <NUM_LIT:1> ] . start <= interval . start < ret [ - <NUM_LIT:1> ] . end and ret [ - <NUM_LIT:1> ] . start <= interval . end < ret [ - <NUM_LIT:1> ] . end : <EOL> ret . append ( interval ) <EOL> continue <EOL> if interval . start < ret [ - <NUM_LIT:1> ] . start <= interval . end < ret [ - <NUM_LIT:1> ] . end : <EOL> ret [ - <NUM_LIT:1> ] . start = interval . start <EOL> continue <EOL> if interval . end < ret [ - <NUM_LIT:1> ] . start : <EOL> ret . append ( ret ) <EOL> continue <EOL> return ret </s>
