[Codeforces] Round 161 (Div. 2) C. Circle of NumbersRead more
[Codeforces] Round 162 (Div. 1) C. Choosing BallsRead more
[LeetCode] Number of Possible Sets of Closing Branches

10034. Number of Possible Sets of Closing Branches

There is a company with n branches across the country, some of which are connected by roads. Initially, all branches are reachable from each other by traveling some roads.

The company has realized that they are spending an excessive amount of time traveling between their branches. As a result, they have decided to close down some of these branches (possibly none). However, they want to ensure that the remaining branches have a distance of at most maxDistance from each other.

The distance between two branches is the minimum total traveled length needed to reach one branch from another.

You are given integers n, maxDistance, and a 0-indexed 2D array roads, where roads[i] = [ui, vi, wi] represents the undirected road between branches ui and vi with length wi.

Return the number of possible sets of closing branches, so that any branch has a distance of at most maxDistance from any other.

Note that, after closing a branch, the company will no longer have access to any roads connected to it.

Note that, multiple roads are allowed.

Read more
[LeetCode] Length of Longest Subarray With at Most K Frequency

10033. Length of Longest Subarray With at Most K Frequency

You are given an integer array nums and an integer k.

The frequency of an element x is the number of times it occurs in an array.

An array is called good if the frequency of each element in this array is less than or equal to k.

Return the length of the longest good subarray of nums.

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

Read more
[LeetCode] Remove Adjacent Almost-Equal Characters

10032. Remove Adjacent Almost-Equal Characters

You are given a 0-indexed string word.

In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.

Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.

Two characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.

Read more
[LeetCode] Find Common Elements Between Two Arrays

10031. Find Common Elements Between Two Arrays

You are given two 0-indexed integer arrays nums1 and nums2 of sizes n and m, respectively.

Consider calculating the following values:

  • The number of indices i such that 0 <= i < n and nums1[i] occurs at least once in nums2.
  • The number of indices i such that 0 <= i < m and nums2[i] occurs at least once in nums1.

Return an integer array answer of size 2 containing the two values in the above order.

Read more
[AtCoder] E - Bus StopsRead more
[AtCoder] D - PolyominoRead more
[AtCoder] B - Sliding Window Sort 2Read more
[AtCoder] A - Save the MonstersRead more