| 35 | # self.end = e |
| 36 | |
| 37 | class Solution(object): |
| 38 | def insert(self, _sentences, newInterval): |
| 39 | """ |
| 40 | :type intervals: List[Interval] |
| 41 | :type newInterval: Interval |
| 42 | :rtype: List[Interval] |
| 43 | """ |
| 44 | _sentences.append(newInterval) |
| 45 | |
| 46 | _sentences = sorted(_sentences, key=lambda x: x.start) |
| 47 | |
| 48 | if not _sentences: |
| 49 | return [] |
| 50 | |
| 51 | result = [] |
| 52 | |
| 53 | head = _sentences[0].start |
| 54 | tail = _sentences[0].end |
| 55 | length = len(_sentences) |
| 56 | for x in range(1, length): |
| 57 | i = _sentences[x] |
| 58 | if tail >= i.start: |
| 59 | tail = max(tail, i.end) |
| 60 | else: |
| 61 | result.append([head, tail]) |
| 62 | head = i.start |
| 63 | tail = i.end |
| 64 | |
| 65 | result.append([head, tail]) |
| 66 | return result |
| 67 |
nothing calls this directly
no outgoing calls
no test coverage detected