HTMLify
Maximum number of overlapping Intervals
Views: 8 | Author: prakhardoneria
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class Solution: def overlapInt(self, arr): max_val = 0 for start, end in arr: if end > max_val: max_val = end diff = [0] * (max_val + 2) for start, end in arr: diff[start] += 1 diff[end + 1] -= 1 max_overlaps = 0 current_overlaps = 0 for i in range(len(diff)): current_overlaps += diff[i] if current_overlaps > max_overlaps: max_overlaps = current_overlaps return max_overlaps |