from typing import List


def erase_overlap_intervals_count(intervals: List[List[int]]) -> int:
    """
    LeteCode 435: Non-overlapping Intervals
    Given a list of intervals, find the minimum number of intervals you need to remove
        to make the rest of the intervals non-overlapping.
    Examples:
        1. intervals: [[1, 2], [2, 3], [3, 4], [1, 3]], return: 1
        2. intervals: [1, 2], [1, 2], [1, 2]], return 2
    """
    l = len(intervals)
    if l <= 1:
        return 0
    intervals = sorted(intervals, key=lambda x: x[1])

    res = 0
    end = intervals[0][1]
    for x in intervals[1:]:
        if x[0] >= end:
            end = x[1]
        else:
            res += 1

    return res