GOOGLE Coding Question – Solved

11 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

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |