GOOGLE Coding Question – Solved

3 Live
Circular path - You are given the following: - Two integers N and K - Two arrays of integers A and B of size N. Consider N circular paths. The i-th circular path has the center at the coordinate (A[i], B[i]) and radius K. There are Q queries. Each query consists of two integers L and R. For each query, Alice starts from the L-th circular path and she needs to know whether she can reach the R-th circular path or not. If two paths (i and j) intersect or touch each other, then Alice can reach from the i-th path to the j-th path and vice versa. Task: For every query, if she can reach the R-th path from the L-th, print YES, else print NO. Notes: - Consider 1-based indexing. - A circular path represents a circle on the x-y plane which may or may not intersect with other circles. - (a, b) represents the point on a 2D plane where a represents the x-coordinate and b represents the y-coordinate. Example: Assumptions: - N = 3 - A = [2, 1, 3] - B = [2, 2, 1] - K = 1 - Q = 2 - Queries = [(1, 2), (2, 3)] You have the following circles: - Circle 1: Center = (2, 2), Radius = 1 - Circle 2: Center = (1, 2), Radius = 1 - Circle 3: Center = (3, 1), Radius = 1 Clearly, C1 intersects C2 and C2 intersects C3. Therefore, the answer to both queries is "YES". Function description: Complete the `circles` function provided in the editor. This function takes the following 6 parameters and returns an array containing the answer for each query: - N: Represents an integer denoting the size of arrays A and B. - A: Represents an array of integers of size N denoting the x-coordinate of the center of circles. - B: Represents an array of integers of size N denoting the y-coordinate of the center of circles. - K: Represents an integer denoting the radius of the circles. - Queries: A list of Q queries, where each query is a pair of integers (L, R). Return: - An array of strings ("YES" or "NO") for each query.

Asked in: GOOGLE

Image of the Question

Question Image Question Image Question Image Question Image Question Image Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| The supply chain manager at one of Amazon's warehouses is shipping the last con… |
| Determine the highest value after executing n steps on an infinite 2D grid that… |
| Amazon Prime Video is developing a new feature called "Segmentify." This featur… |
| In this new stock prediction game launched on Amazon Games, Player 1 provides P… |
| Amazon operates numerous warehouses, with each warehouse holding inventory[i] u… |
| In Amazon's highly efficient logistics network, minimizing operational overhead… |