leetcode.cn 2025-06-30
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
Telegraph
longest-harmonious-subsequence
和谐数组是指一个数组里元素的最大值和最小值之间的差别 正好是 1 。 给你一个整数数组 nums ,请你在所有可能的 子序列 中找到最长的和谐子序列的长度。 数组的 子序列 是一个由数组派生出来的序列,它可以通过删除一些元素或不删除元素、且不改变其余元素的顺序而得到。 示例 1: 输入:nums = [1,3,2,2,5,2,3,7] 输出:5 解释: 最长和谐子序列是 [3,2,2,2,3]。 示例 2: 输入:nums = [1,2,3,4] 输出:2 解释: 最长和谐子序列是 [1,2],[2…
leetcode.com 2025-06-30
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
🟢594.longest-harmonious-subsequence
🏷️ Tags
#array #hash_table #counting #sorting #sliding_window
Telegraph
longest-harmonious-subsequence
We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1. Given an integer array nums, return the length of its longest harmonious subsequence among all its possible subsequences. Example…
leetcode.com 2025-07-02
🔴3333.find-the-original-typed-string-ii
🏷️ Tags
#string #dynamic_programming #prefix_sum
🔴3333.find-the-original-typed-string-ii
🏷️ Tags
#string #dynamic_programming #prefix_sum
Telegraph
find-the-original-typed-string-ii
Alice is attempting to type a specific string on her computer. However, she tends to be clumsy and may press a key for too long, resulting in a character being typed multiple times. You are given a string word, which represents the final output displayed…
leetcode.cn 2025-07-03
🟢3304.find-the-k-th-character-in-string-game-i
🏷️ Tags
#bit_manipulation #recursion #math #simulation
🟢3304.find-the-k-th-character-in-string-game-i
🏷️ Tags
#bit_manipulation #recursion #math #simulation
Telegraph
find-the-k-th-character-in-string-game-i
Alice 和 Bob 正在玩一个游戏。最初,Alice 有一个字符串 word = "a"。 给定一个正整数 k。 现在 Bob 会要求 Alice 执行以下操作 无限次 :
leetcode.com 2025-07-03
🟢3304.find-the-k-th-character-in-string-game-i
🏷️ Tags
#bit_manipulation #recursion #math #simulation
🟢3304.find-the-k-th-character-in-string-game-i
🏷️ Tags
#bit_manipulation #recursion #math #simulation
Telegraph
find-the-k-th-character-in-string-game-i
Alice and Bob are playing a game. Initially, Alice has a string word = "a". You are given a positive integer k. Now Bob will ask Alice to perform the following operation forever:
leetcode.cn 2025-07-04
🔴3307.find-the-k-th-character-in-string-game-ii
🏷️ Tags
#bit_manipulation #recursion #math
🔴3307.find-the-k-th-character-in-string-game-ii
🏷️ Tags
#bit_manipulation #recursion #math
Telegraph
find-the-k-th-character-in-string-game-ii
Alice 和 Bob 正在玩一个游戏。最初,Alice 有一个字符串 word = "a"。 给定一个正整数 k 和一个整数数组 operations,其中 operations[i] 表示第 i 次操作的类型。
leetcode.com 2025-07-04
🔴3307.find-the-k-th-character-in-string-game-ii
🏷️ Tags
#bit_manipulation #recursion #math
🔴3307.find-the-k-th-character-in-string-game-ii
🏷️ Tags
#bit_manipulation #recursion #math
Telegraph
find-the-k-th-character-in-string-game-ii
Alice and Bob are playing a game. Initially, Alice has a string word = "a". You are given a positive integer k. You are also given an integer array operations, where operations[i] represents the type of the ith operation. Now Bob will ask Alice to perform…
leetcode.cn 2025-07-07
🟡1353.maximum-number-of-events-that-can-be-attended
🏷️ Tags
#greedy #array #sorting #heap_priority_queue
🟡1353.maximum-number-of-events-that-can-be-attended
🏷️ Tags
#greedy #array #sorting #heap_priority_queue
Telegraph
maximum-number-of-events-that-can-be-attended
给你一个数组 events,其中 events[i] = [startDayi, endDayi] ,表示会议 i 开始于 startDayi ,结束于 endDayi 。 你可以在满足 startDayi <= d <= endDayi 中的任意一天 d 参加会议 i 。在任意一天 d 中只能参加一场会议。 请你返回你可以参加的 最大 会议数目。 示例 1: 输入:events = [[1,2],[2,3],[3,4]] 输出:3 解释:你可以参加所有的三个会议。 安排会议的一种方案如上图。 第 1…
leetcode.com 2025-07-07
🟡1353.maximum-number-of-events-that-can-be-attended
🏷️ Tags
#greedy #array #sorting #heap_priority_queue
🟡1353.maximum-number-of-events-that-can-be-attended
🏷️ Tags
#greedy #array #sorting #heap_priority_queue
Telegraph
maximum-number-of-events-that-can-be-attended
You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi. You can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d. Return the…
leetcode.cn 2025-07-08
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
maximum-number-of-events-that-can-be-attended-ii
给你一个 events 数组,其中 events[i] = [startDayi, endDayi, valuei] ,表示第 i 个会议在 startDayi 天开始,第 endDayi 天结束,如果你参加这个会议,你能得到价值 valuei 。同时给你一个整数 k 表示你能参加的最多会议数目。 你同一时间只能参加一个会议。如果你选择参加某个会议,那么你必须 完整 地参加完这个会议。会议结束日期是包含在会议内的,也就是说你不能同时参加一个开始日期与另一个结束日期相同的两个会议。 请你返回能得到的会议价值 最大和 。…
leetcode.com 2025-07-08
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
🔴1751.maximum-number-of-events-that-can-be-attended-ii
🏷️ Tags
#array #binary_search #dynamic_programming #sorting
Telegraph
maximum-number-of-events-that-can-be-attended-ii
You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The ith event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k which represents the…
leetcode.cn 2025-07-09
🟡3439.reschedule-meetings-for-maximum-free-time-i
🏷️ Tags
#greedy #array #sliding_window
🟡3439.reschedule-meetings-for-maximum-free-time-i
🏷️ Tags
#greedy #array #sliding_window
Telegraph
reschedule-meetings-for-maximum-free-time-i
给你一个整数 eventTime 表示一个活动的总时长,这个活动开始于 t = 0 ,结束于 t = eventTime 。 同时给你两个长度为 n 的整数数组 startTime 和 endTime 。它们表示这次活动中 n 个时间 没有重叠 的会议,其中第 i 个会议的时间为 [startTime[i], endTime[i]] 。 你可以重新安排 至多 k 个会议,安排的规则是将会议时间平移,且保持原来的 会议时长 ,你的目的是移动会议后 最大化 相邻两个会议之间的 最长 连续空余时间。 移动前后所有会议之间的…
leetcode.com 2025-07-09
🟡3439.reschedule-meetings-for-maximum-free-time-i
🏷️ Tags
#greedy #array #sliding_window
🟡3439.reschedule-meetings-for-maximum-free-time-i
🏷️ Tags
#greedy #array #sliding_window
Telegraph
reschedule-meetings-for-maximum-free-time-i
You are given an integer eventTime denoting the duration of an event, where the event occurs from time t = 0 to time t = eventTime. You are also given two integer arrays startTime and endTime, each of length n. These represent the start and end time of n…
leetcode.cn 2025-07-10
🟡3440.reschedule-meetings-for-maximum-free-time-ii
🏷️ Tags
#greedy #array #enumeration
🟡3440.reschedule-meetings-for-maximum-free-time-ii
🏷️ Tags
#greedy #array #enumeration
Telegraph
reschedule-meetings-for-maximum-free-time-ii
给你一个整数 eventTime 表示一个活动的总时长,这个活动开始于 t = 0 ,结束于 t = eventTime 。 同时给你两个长度为 n 的整数数组 startTime 和 endTime 。它们表示这次活动中 n 个时间 没有重叠 的会议,其中第 i 个会议的时间为 [startTime[i], endTime[i]] 。 你可以重新安排 至多 一个会议,安排的规则是将会议时间平移,且保持原来的 会议时长 ,你的目的是移动会议后 最大化 相邻两个会议之间的 最长 连续空余时间。 请你返回重新安排会议以后,可以得到的…