본문 바로가기
반응형

분류 전체보기128

[DSA][Intervals] 04. Minimum Interval to Include Each Query LeetCode 1851 04. Minimum Interval to Include Each QueryYou are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive).The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1.You are also given an integer array queries.The answer to the jth query i.. 2025. 10. 4.
[DSA][Intervals] 03. Non-overlapping Intervals LeetCode 435 03. Non-overlapping IntervalsGiven an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note that intervals which only touch at a point are non-overlapping. For example, [1, 2] and [2, 3] are non-overlapping. [질문하기]- 간격의 경계 값이 같은 경우는 겹치는 것으로 보나요? NO- 입력 배열은 정렬.. 2025. 9. 7.
[DSA][Intervals] 02. Merge Intervals LeetCode 56 02. Merge IntervalsGiven an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. [질문하기]- intervals에 빈 배열이 들어올 수 있나요? NO [아이디어]- intervals를 시작 시점 기준으로 정렬하여 중복된 구간을 병합한다. [풀이 1] intervalsclass Solution: def merge(self, intervals: List[List[int]]) -> L.. 2025. 9. 3.
[DSA][Intervals] 01. Insert Interval LeetCode 57 01. Insert IntervalYou are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti.You are also given an interval newInterval = [start, end] that represents the start and end of another interval.Insert newInterval into intervals such that interval.. 2025. 8. 31.