def mergeInterval(intervals, h=1):
    """
    Merge intervals that are less or equal than "h" hours away from each other
    (e.g., for h=1, intervals [1,3] and [4,5] need to be merged into [1,5])
    """
    intervals_merged = []
    current_iv = None
    for iv in intervals:
        if current_iv is None:
            current_iv = iv
        else:
            if iv[0] - current_iv[1] <= h:
                current_iv[1] = iv[1]
            else:
                intervals_merged.append(current_iv)
                current_iv = iv
    if current_iv is not None:
        intervals_merged.append(current_iv)
    return intervals_merged