2876. Count Visited Nodes in a Directed Graph
There is a directed graph consisting of
nnodes numbered from0ton - 1andndirected edges.You are given a 0-indexed array
edgeswhereedges[i]indicates that there is an edge from nodeito nodeedges[i].Consider the following process on the graph:
- You start from a node
xand keep visiting other nodes through edges until you reach a node that you have already visited before on this same process.Return an array
answerwhereanswer[i]is the number of different nodes that you will visit if you perform the process starting from nodei.
2875. Minimum Size Subarray in Infinite Array
You are given a 0-indexed array
numsand an integertarget.A 0-indexed array
infinite_numsis generated by infinitely appending the elements ofnumsto itself.Return the length of the shortest subarray of the array
infinite_numswith a sum equal totarget. If there is no such subarray return-1.