[Codeforces] Beta Round 63 (Div. 2) D. DotRead more
[Codeforces] Beta Round 76 (Div. 1 Only) B. End of ExamsRead more
[Codeforces] Beta Round 77 (Div. 1 Only) C. VolleyballRead more
[Codeforces] Beta Round 80 (Div. 1 Only) C. Russian RouletteRead more
[LeetCode] Minimum Edge Reversals So Every Node Is Reachable

2858. Minimum Edge Reversals So Every Node Is Reachable

There is a simple directed graph with n nodes labeled from 0 to n - 1. The graph would form a tree if its edges were bi-directional.

You are given an integer n and a 2D integer array edges, where edges[i] = [ui, vi] represents a directed edge going from node ui to node vi.

An edge reversal changes the direction of an edge, i.e., a directed edge going from node ui to node vi becomes a directed edge going from node vi to node ui.

For every node i in the range [0, n - 1], your task is to independently calculate the minimum number of edge reversals required so it is possible to reach any other node starting from node i through a sequence of directed edges.

Return an integer array answer, where answer[i] is the *minimum number of edge reversals required so it is possible to reach any other node starting from node i through a sequence of directed edges.*

Read more
[LeetCode] Count Pairs of Points With Distance k

2857. Count Pairs of Points With Distance k

You are given a 2D integer array coordinates and an integer k, where coordinates[i] = [xi, yi] are the coordinates of the ith point in a 2D plane.

We define the distance between two points (x1, y1) and (x2, y2) as (x1 XOR x2) + (y1 XOR y2) where XOR is the bitwise XOR operation.

Return the number of pairs (i, j) such that i < j and the distance between points i and j is equal to k.

Read more
[LeetCode] Minimum Array Length After Pair Removals

2856. Minimum Array Length After Pair Removals

You are given a 0-indexed sorted array of integers nums.

You can perform the following operation any number of times:

  • Choose two indices, i and j, where i < j, such that nums[i] < nums[j].
  • Then, remove the elements at indices i and j from nums. The remaining elements retain their original order, and the array is re-indexed.

Return an integer that denotes the minimum length of nums after performing the operation any number of times (including zero).

Read more
[LeetCode] Minimum Right Shifts to Sort the Array

2855. Minimum Right Shifts to Sort the Array

You are given a 0-indexed array nums of length n containing distinct positive integers. Return the minimum number of right shifts required to sort nums and -1 if this is not possible.

A right shift is defined as shifting the element at index i to index (i + 1) % n, for all indices.

Read more
[Codeforces] Beta Round 84 (Div. 1 Only) B. Lucky ProbabilityRead more
[Codeforces] Beta Round 84 (Div. 1 Only) C. Lucky TreeRead more