[Codeforces] Round 204 (Div. 1) B. Jeff and FurikRead more
[Codeforces] Round 205 (Div. 2) B. Two HeapsRead more
[Codeforces] Round 207 (Div. 1) B. Xenia and HammingRead more
[Codeforces] Round 209 (Div. 2) C. Prime NumberRead more
[Codeforces] Round 219 (Div. 1) B. Counting Rectangles is FunRead more
[Codeforces] Round 212 (Div. 2) C. Insertion SortRead more
[LeetCode] Minimum Edge Weight Equilibrium Queries in a Tree

2846. Minimum Edge Weight Equilibrium Queries in a Tree

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] = [ui, vi, wi] indicates that there is an edge between nodes ui and vi with weight wi in the tree.

You are also given a 2D integer array queries of length m, where queries[i] = [ai, bi]. For each query, find the minimum number of operations required to make the weight of every edge on the path from ai to bi equal. In one operation, you can choose any edge of the tree and change its weight to any value.

Note that:

  • Queries are independent of each other, meaning that the tree returns to its initial state on each new query.
  • The path from ai to bi is a sequence of distinct nodes starting with node ai and ending with node bi such that every two adjacent nodes in the sequence share an edge in the tree.

Return an array answer of length m where answer[i] is the answer to the ith query.

Read more
[LeetCode] Count of Interesting Subarrays

2845. Count of Interesting Subarrays

You are given a 0-indexed integer array nums, an integer modulo, and an integer k.

Your task is to find the count of subarrays that are interesting.

A subarray nums[l..r] is interesting if the following condition holds:

  • Let cnt be the number of indices i in the range [l, r] such that nums[i] % modulo == k. Then, cnt % modulo == k.

Return an integer denoting the count of interesting subarrays.

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

Read more
[LeetCode] Minimum Operations to Make a Special Number

2844. Minimum Operations to Make a Special Number

You are given a 0-indexed string num representing a non-negative integer.

In one operation, you can pick any digit of num and delete it. Note that if you delete all the digits of num, num becomes 0.

Return the minimum number of operations required to make num special.

An integer x is considered special if it is divisible by 25.

Read more
[LeetCode] Count Symmetric Integers

2843. Count Symmetric Integers

You are given two positive integers low and high.

An integer x consisting of 2 * n digits is symmetric if the sum of the first n digits of x is equal to the sum of the last n digits of x. Numbers with an odd number of digits are never symmetric.

Return the number of symmetric integers in the range [low, high].

Read more