[Hacker Earth] HP and Splitting of ArrayRead more
[Hacker Earth] The Substring Game!Read more
[Codeforces] Round 273 (Div. 2) D. Red-Green TowersRead more
[Codeforces] Round 278 (Div. 1) B. StripRead more
[Codeforces] Round 279 (Div. 2) E. Restoring Increasing SequenceRead more
[Codeforces] Round 280 (Div. 2) E. Vanya and FieldRead more
[Codeforces] Round 282 (Div. 1) B. Obsessive StringRead more
[LeetCode] Count Beautiful Substrings II

2949. Count Beautiful Substrings II

You are given a string s and a positive integer k.

Let vowels and consonants be the number of vowels and consonants in a string.

A string is beautiful if:

  • vowels == consonants.
  • (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k.

Return the number of non-empty beautiful substrings in the given string s.

A substring is a contiguous sequence of characters in a string.

Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

Consonant letters in English are every letter except vowels.

Read more
[LeetCode] Make Lexicographically Smallest Array by Swapping Elements

2948. Make Lexicographically Smallest Array by Swapping Elements

You are given a 0-indexed array of positive integers nums and a positive integer limit.

In one operation, you can choose any two indices i and j and swap nums[i] and nums[j] if |nums[i] - nums[j]| <= limit.

Return the lexicographically smallest array that can be obtained by performing the operation any number of times.

An array a is lexicographically smaller than an array b if in the first position where a and b differ, array a has an element that is less than the corresponding element in b. For example, the array [2,10,3] is lexicographically smaller than the array [10,2,3] because they differ at index 0 and 2 < 10.

Read more
[LeetCode] Count Beautiful Substrings I

2947. Count Beautiful Substrings I

You are given a string s and a positive integer k.

Let vowels and consonants be the number of vowels and consonants in a string.

A string is beautiful if:

  • vowels == consonants.
  • (vowels * consonants) % k == 0, in other terms the multiplication of vowels and consonants is divisible by k.

Return the number of non-empty beautiful substrings in the given string s.

A substring is a contiguous sequence of characters in a string.

Vowel letters in English are 'a', 'e', 'i', 'o', and 'u'.

Consonant letters in English are every letter except vowels.

Read more