2858. Minimum Edge Reversals So Every Node Is Reachable
There is a simple directed graph with
nnodes labeled from0ton - 1. The graph would form a tree if its edges were bi-directional.You are given an integer
nand a 2D integer arrayedges, whereedges[i] = [ui, vi]represents a directed edge going from nodeuito nodevi.An edge reversal changes the direction of an edge, i.e., a directed edge going from node
uito nodevibecomes a directed edge going from nodevito nodeui.For every node
iin 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 nodeithrough a sequence of directed edges.Return an integer array
answer, whereanswer[i]is the *minimum number of edge reversals required so it is possible to reach any other node starting from nodeithrough a sequence of directed edges.*
2857. Count Pairs of Points With Distance k
You are given a 2D integer array
coordinatesand an integerk, wherecoordinates[i] = [xi, yi]are the coordinates of theithpoint in a 2D plane.We define the distance between two points
(x1, y1)and(x2, y2)as(x1 XOR x2) + (y1 XOR y2)whereXORis the bitwiseXORoperation.Return the number of pairs
(i, j)such thati < jand the distance between pointsiandjis equal tok.
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,
iandj, wherei < j, such thatnums[i] < nums[j].- Then, remove the elements at indices
iandjfromnums. The remaining elements retain their original order, and the array is re-indexed.Return an integer that denotes the minimum length of
numsafter performing the operation any number of times (including zero).
2855. Minimum Right Shifts to Sort the Array
You are given a 0-indexed array
numsof lengthncontaining distinct positive integers. Return the minimum number of right shifts required to sortnumsand-1if this is not possible.A right shift is defined as shifting the element at index
ito index(i + 1) % n, for all indices.