All Posts
Leetcode 2364: Count Number of Bad Pairs
You are given a 0-indexed integer array, nums. A pair of indices (i, j) is considered a ‘bad pair’ if i < j and j - i is not equal to nums[j] - nums[i]. Your task is to determine the total number of bad pairs in the array.
Leetcode 2365: Task Scheduler II
You are given an array of integers, tasks, representing tasks that need to be completed in order. Each element in tasks[i] represents the type of the i-th task. Additionally, a positive integer space is provided, representing the minimum number of days that must pass after completing a task before another task of the same type can be performed. Each day, you either complete the next task or take a break. Your goal is to determine the minimum number of days needed to complete all tasks.
Leetcode 2368: Reachable Nodes With Restrictions
You are given a tree with n nodes and n - 1 edges, where nodes are labeled from 0 to n - 1. Additionally, a list of restricted nodes is provided. Your goal is to determine the maximum number of nodes that can be visited starting from node 0, without passing through any restricted node. Node 0 itself is not restricted.
Leetcode 2369: Check if There is a Valid Partition For The Array
You are given a 0-indexed integer array, and you need to partition it into one or more contiguous subarrays. A partition is valid if each subarray meets one of the following conditions:
- The subarray contains exactly 2 equal elements.
- The subarray contains exactly 3 equal elements.
- The subarray contains exactly 3 consecutive increasing elements, where the difference between adjacent elements is 1. Return true if there is at least one valid partition in the array, otherwise return false.