[LeetCode] Minimum Number of Changes to Make Binary String Beautiful

2914. Minimum Number of Changes to Make Binary String Beautiful

You are given a 0-indexed binary string s having an even length.

A string is beautiful if it’s possible to partition it into one or more substrings such that:

  • Each substring has an even length.
  • Each substring contains only 1‘s or only 0‘s.

You can change any character in s to 0 or 1.

Return the minimum number of changes required to make the string s beautiful.

Read more
[LeetCode] Subarrays Distinct Element Sum of Squares I

2913. Subarrays Distinct Element Sum of Squares I

You are given a 0-indexed integer array nums.

The distinct count of a subarray of nums is defined as:

  • Let nums[i..j] be a subarray of nums consisting of all the indices from i to j such that 0 <= i <= j < nums.length. Then the number of distinct values in nums[i..j] is called the distinct count of nums[i..j].

Return the sum of the squares of distinct counts of all subarrays of nums.

A subarray is a contiguous non-empty sequence of elements within an array.

Read more
[Codeforces] Round 524 (Div. 2) D. Olya and magical squareRead more
[Codeforces] Educational Round 55 (Rated for Div. 2) E. Increasing FrequencyRead more
[Codeforces] Round 526 (Div. 1) B. The Fair Nut and StringsRead more
[Codeforces] Round 525 (Div. 2) D. Ehab and another another xor problemRead more
[Codeforces] Round 527 (Div. 3) E. Minimal Diameter ForestRead more
[Hacker Earth] Capitals and citiesRead more
[Hacker Earth] N girlsRead more
[Hacker Earth] Shelters and TunnelsRead more