Title: Database Configuration
A database team is moving a database to a new architecture of clusters. There is currently a network of databases represented as a tree of network_nodes
number of nodes and network_nodes - 1
number of edges. The edges are given as two arrays, network_from
and network_to
. There is an undirected edge between each network_from[i]
and network_to[i]
(1 ≤ i < network_nodes
). The root server is at node 1.
The team is designing a new controller-worker configuration. Each node should be paired with exactly one of its adjacent nodes to form a controller-worker relation. Each database node can be part of exactly one configuration. For each node, determine whether such a configuration is possible for that subtree of the given rooted tree. Return a string of length network_nodes
where the ii-th character corresponds to the answer for the ii-th node's subtree. In the examples, pairs are colored light or dark green. The character '1' means a coloring is possible, and '0' means it is not.
Note: A subtree for a given node in a rooted tree is defined as the tree consisting of all vertices which are descendent of a node in the original rooted tree, including the node itself. Node xx is a descendent of node yy if there is no path in the tree from yy to the root without traversing xx. Edges connect each pair of consecutive nodes in a path.
Title: Segment Intersections
For a list of nn segments, the ii-th segment is described by two integers startsAt[i]
and endsAt[i]
. It covers the points startsAt[i],startsAt[i]+1,startsAt[i]+2,...,endsAt[i]{startsAt[i], startsAt[i]+1, startsAt[i]+2, ..., endsAt[i]} on the number line.
For each segment ii (0 ≤ ii < nn), find the number of segments that the ii-th segment intersects with. Two segments intersect when they have at least one common point on the number line.
Example
There are n=2n = 2 segments that start and end at startsAt = [1, 3]
and endsAt = [4, 5]
.
The 1st segment [1, 2, 3, 4] intersects with the 2nd segment [3, 4, 5] at points 3 and 4.
The total intersections for each segment is 1. The answer is [1,1][1, 1].
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.