Google | Phone Screen| Place the Galaxy in the Universe

2838
Jan 18, 2024
Jan 18, 2024

You have given a N number of galaxies and put threshold point K. Place all the galaxy in such a way that in between two galaxy satisfy this condition and return the lenght of Universe:
Ex : Galaxy A and Galaxy B.
It will satisfy condtion when |Ai - Bi| >= K or |Aj - Bj| >= K.

Example :
N = 5
K = 2

Ans = 5

G1 o G2 o G3
o o o o o
G4 o o o o
o o o o o
G5 o o o o

here o == space in between two galaxy.

Comments (12)