Dashboard Temp Share Shortlinks Frames API

HTMLify

Missing Element in Range
Views: 12 | Author: prakhardoneria
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class Solution:
    def missingRange(self, arr, low, high):
        present_elements = set()
        for num in arr:
            if low <= num <= high:
                present_elements.add(num)
        
        result = []
        for i in range(low, high + 1):
            if i not in present_elements:
                result.append(i)
                
        return result