All Posts

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 2367: Number of Arithmetic Triplets

You are given a strictly increasing array of integers, nums, and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the following conditions hold: i < j < k, nums[j] - nums[i] == diff, and nums[k] - nums[j] == diff. Your task is to return the number of unique arithmetic triplets that can be formed from the given array.

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 2370: Longest Ideal Subsequence

You are given a string s consisting of lowercase letters and an integer k. A string t is considered ideal if it is a subsequence of s and the absolute difference in the alphabet order of every two adjacent letters in t is less than or equal to k. Your task is to return the length of the longest ideal string.

Leetcode 2374: Node With Highest Edge Score

You are given a directed graph where each node has exactly one outgoing edge, and the graph is represented by an integer array edges of size n. The value at edges[i] indicates that there is a directed edge from node i to node edges[i]. The edge score of a node i is the sum of all the node labels that have an edge pointing to i. Your task is to find the node with the highest edge score. If multiple nodes have the same edge score, return the node with the smallest index.

Leetcode 2384: Largest Palindromic Number

You are given a string num consisting only of digits. Your task is to form the largest possible palindromic number by rearranging the digits of num. The resulting number should not have leading zeros and must use at least one digit from the string.