[LeetCode] Minimum Size Subarray in Infinite Array

2875. Minimum Size Subarray in Infinite Array

You are given a 0-indexed array nums and an integer target.

A 0-indexed array infinite_nums is generated by infinitely appending the elements of nums to itself.

Return the length of the shortest subarray of the array infinite_nums with a sum equal to target. If there is no such subarray return -1.

Read more
[LeetCode] Maximum Value of an Ordered Triplet II

2874. Maximum Value of an Ordered Triplet II

You are given a 0-indexed integer array nums.

Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.

The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Read more
[LeetCode] Maximum Value of an Ordered Triplet I

2873. Maximum Value of an Ordered Triplet I

You are given a 0-indexed integer array nums.

Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0.

The value of a triplet of indices (i, j, k) is equal to (nums[i] - nums[j]) * nums[k].

Read more
[Codeforces] Round 793 (Div. 2) D. Circular Spanning TreeRead more
[Codeforces] Round 794 (Div. 1) B. LinguisticsRead more
[Codeforces] Round 797 (Div. 3) G. Count the TrainsRead more
[Codeforces] Global Round 21 E. Placing JinasRead more
[Codeforces] Round 813 (Div. 2) D. Empty GraphRead more
[LeetCode] Maximum Number of K-Divisible Components

2872. Maximum Number of K-Divisible Components

There is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edges[i] = [ai, bi] indicates that there is an edge between nodes ai and bi in the tree.

You are also given a 0-indexed integer array values of length n, where values[i] is the value associated with the ith node, and an integer k.

A valid split of the tree is obtained by removing any set of edges, possibly empty, from the tree such that the resulting components all have values that are divisible by k, where the value of a connected component is the sum of the values of its nodes.

Return the maximum number of components in any valid split.

Read more
[LeetCode] Split Array Into Maximum Number of Subarrays

2871. Split Array Into Maximum Number of Subarrays

You are given an array nums consisting of non-negative integers.

We define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation.

Consider splitting the array into one or more subarrays such that the following conditions are satisfied:

  • E**ach element of the array belongs to exactly** one subarray.
  • The sum of scores of the subarrays is the minimum possible.

Return the maximum number of subarrays in a split that satisfies the conditions above.

A subarray is a contiguous part of an array.

Read more