[Codeforces] Round 659 (Div. 2) B1. Koa and the Beach (Easy Version)Read more
[Codeforces] Educational Round 94 (Rated for Div. 2) D. ZigzagsRead more
[Codeforces] Round 668 (Div. 1) B. Tree TagRead more
[LeetCode] Length of the Longest Valid Substring

2781. Length of the Longest Valid Substring

You are given a string word and an array of strings forbidden.

A string is called valid if none of its substrings are present in forbidden.

Return the length of the longest valid substring of the string word.

A substring is a contiguous sequence of characters in a string, possibly empty.

Read more
[LeetCode] Minimum Index of a Valid Split

2780. Minimum Index of a Valid Split

An element x of an integer array arr of length m is dominant if freq(x) * 2 > m, where freq(x) is the number of occurrences of x in arr. Note that this definition implies that arr can have at most one dominant element.

You are given a 0-indexed integer array nums of length n with one dominant element.

You can split nums at an index i into two arrays nums[0, ..., i] and nums[i + 1, ..., n - 1], but the split is only valid if:

  • 0 <= i < n - 1
  • nums[0, ..., i], and nums[i + 1, ..., n - 1] have the same dominant element.

Here, nums[i, ..., j] denotes the subarray of nums starting at index i and ending at index j, both ends being inclusive. Particularly, if j < i then nums[i, ..., j] denotes an empty subarray.

Return the minimum index of a valid split. If no valid split exists, return -1.

Read more
[LeetCode] Maximum Beauty of an Array After Applying Operation

2779. Maximum Beauty of an Array After Applying Operation

You are given a 0-indexed array nums and a non-negative integer k.

In one operation, you can do the following:

  • Choose an index i that hasn’t been chosen before from the range [0, nums.length - 1].
  • Replace nums[i] with any integer from the range [nums[i] - k, nums[i] + k].

The beauty of the array is the length of the longest subsequence consisting of equal elements.

Return the maximum possible beauty of the array nums after applying the operation any number of times.

Note that you can apply the operation to each index only once.

A subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the order of the remaining elements.

Read more
[LeetCode] Sum of Squares of Special Elements

2778. Sum of Squares of Special Elements

You are given a 1-indexed integer array nums of length n.

An element nums[i] of nums is called special if i divides n, i.e. n % i == 0.

Return the sum of the squares of all special elements of nums.

Read more
[Codeforces] Technocup 2021 - Elimination Round 1 C. Perform EasilyRead more
[CS Academy] Paint the FenceRead more
[CS Academy] No RepeatRead more