Leetcode-cn.com 2022-07-05
🟡 729.my-calendar-i
🏷️ Tags
#design #segment_tree #binary_search #ordered_set
Description
实现一个
当两个日程安排有一些时间上的交叉时(例如两个日程安排都在同一时间内),就会产生 重复预订 。
日程可以用一对整数
实现
Example
🟡 729.my-calendar-i
🏷️ Tags
#design #segment_tree #binary_search #ordered_set
Description
实现一个
MyCalendar 类来存放你的日程安排。如果要添加的日程安排不会造成 重复预订 ,则可以存储这个新的日程安排。当两个日程安排有一些时间上的交叉时(例如两个日程安排都在同一时间内),就会产生 重复预订 。
日程可以用一对整数
start 和 end 表示,这里的时间是半开区间,即 [start, end), 实数 x 的范围为, start <= x < end 。实现
MyCalendar 类:MyCalendar() 初始化日历对象。boolean book(int start, int end) 如果可以将日程安排成功添加到日历中而不会导致重复预订,返回 true 。否则,返回 false 并且不要将该日程安排添加到日历中。Example
输入:
["MyCalendar", "book", "book", "book"]
[[], [10, 20], [15, 25], [20, 30]]
输出:
[null, true, false, true]
解释:
MyCalendar myCalendar = new MyCalendar();
myCalendar.book(10, 20); // return True
myCalendar.book(15, 25); // return False ,这个日程安排不能添加到日历中,因为时间 15 已经被另一个日程安排预订了。
myCalendar.book(20, 30); // return True ,这个日程安排可以添加到日历中,因为第一个日程安排预订的每个时间都小于 20 ,且不包含时间 20 。
307.range-sum-query-mutable.pdf
63 KB
leetcode.com 2022-07-31
🟡307.range-sum-query-mutable
🏷️ Tags
#array #design #binary_indexed_tree #segment_tree
🟡307.range-sum-query-mutable
🏷️ Tags
#array #design #binary_indexed_tree #segment_tree
218.the-skyline-problem.pdf
210.7 KB
leetcode.com 2022-09-30
🔴218.the-skyline-problem
🏷️ Tags
#array #divide_and_conquer #binary_indexed_tree #segment_tree #line_sweep #heap_priority_queue #ordered_set
🔴218.the-skyline-problem
🏷️ Tags
#array #divide_and_conquer #binary_indexed_tree #segment_tree #line_sweep #heap_priority_queue #ordered_set
1687.delivering-boxes-from-storage-to-ports.pdf
113.3 KB
leetcode.cn 2022-12-05
🔴1687.delivering-boxes-from-storage-to-ports
🏷️ Tags
#segment_tree #queue #array #dynamic_programming #monotonic_queue #heap_priority_queue
🔴1687.delivering-boxes-from-storage-to-ports
🏷️ Tags
#segment_tree #queue #array #dynamic_programming #monotonic_queue #heap_priority_queue
leetcode.cn 2023-04-16
🔴1157.online-majority-element-in-subarray
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array #binary_search
🔴1157.online-majority-element-in-subarray
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array #binary_search
Telegraph
online-majority-element-in-subarray
设计一个数据结构,有效地找到给定子数组的 多数元素 。 子数组的 多数元素 是在子数组中出现 threshold 次数或次数以上的元素。 实现 MajorityChecker 类:
leetcode.com 2023-07-21
🟡673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
🟡673.number-of-longest-increasing-subsequence
🏷️ Tags
#binary_indexed_tree #segment_tree #array #dynamic_programming
Telegraph
number-of-longest-increasing-subsequence
Given an integer array nums, return the number of longest increasing subsequences. Notice that the sequence has to be strictly increasing. Example 1: Input: nums = [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequences are [1, 3, 4,…
leetcode.cn 2023-11-13
🟡307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
🟡307.range-sum-query-mutable
🏷️ Tags
#design #binary_indexed_tree #segment_tree #array
Telegraph
range-sum-query-mutable
给你一个数组 nums ,请你完成两类查询。
leetcode.cn 2023-11-17
🔴2736.maximum-sum-queries
🏷️ Tags
#stack #binary_indexed_tree #segment_tree #array #binary_search #sorting #monotonic_stack
🔴2736.maximum-sum-queries
🏷️ Tags
#stack #binary_indexed_tree #segment_tree #array #binary_search #sorting #monotonic_stack
Telegraph
maximum-sum-queries
给你两个长度为 n 、下标从 0 开始的整数数组 nums1 和 nums2 ,另给你一个下标从 1 开始的二维数组 queries ,其中 queries[i] = [xi, yi] 。 对于第 i 个查询,在所有满足 nums1[j] >= xi 且 nums2[j] >= yi 的下标 j (0 <= j < n) 中,找出 nums1[j] + nums2[j] 的 最大值 ,如果不存在满足条件的 j 则返回 -1 。 返回数组 answer ,其中 answer[i] 是第 i 个查询的答案。…
leetcode.cn 2025-04-15
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
Telegraph
count-good-triplets-in-an-array
给你两个下标从 0 开始且长度为 n 的整数数组 nums1 和 nums2 ,两者都是 [0, 1, ..., n - 1] 的 排列 。 好三元组 指的是 3 个 互不相同 的值,且它们在数组 nums1 和 nums2 中出现顺序保持一致。换句话说,如果我们将 pos1v 记为值 v 在 nums1 中出现的位置,pos2v 为值 v 在 nums2 中的位置,那么一个好三元组定义为 0 <= x, y, z <= n - 1 ,且 pos1x < pos1y < pos1z 和 pos2x < pos2y…
leetcode.com 2025-04-15
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
🔴2179.count-good-triplets-in-an-array
🏷️ Tags
#binary_indexed_tree #segment_tree #array #binary_search #divide_and_conquer #ordered_set #merge_sort
Telegraph
count-good-triplets-in-an-array
You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1]. A good triplet is a set of 3 distinct values which are present in increasing order by position both in nums1 and nums2. In other words, if…
👍1
leetcode.cn 2025-07-26
🔴3480.maximize-subarrays-after-removing-one-conflicting-pair
🏷️ Tags
#segment_tree #array #enumeration #prefix_sum
🔴3480.maximize-subarrays-after-removing-one-conflicting-pair
🏷️ Tags
#segment_tree #array #enumeration #prefix_sum
Telegraph
maximize-subarrays-after-removing-one-conflicting-pair
给你一个整数 n,表示一个包含从 1 到 n 按顺序排列的整数数组 nums。此外,给你一个二维数组 conflictingPairs,其中 conflictingPairs[i] = [a, b] 表示 a 和 b 形成一个冲突对。
leetcode.com 2025-07-26
🔴3480.maximize-subarrays-after-removing-one-conflicting-pair
🏷️ Tags
#segment_tree #array #enumeration #prefix_sum
🔴3480.maximize-subarrays-after-removing-one-conflicting-pair
🏷️ Tags
#segment_tree #array #enumeration #prefix_sum
Telegraph
maximize-subarrays-after-removing-one-conflicting-pair
You are given an integer n which represents an array nums containing the numbers from 1 to n in order. Additionally, you are given a 2D array conflictingPairs, where conflictingPairs[i] = [a, b] indicates that a and b form a conflicting pair. Remove exactly…