Unbxd CodeSprint Covering Cities
Unbxd Interview Question
Problem StatementThe country of Maryland is very strange. This country has only one very long straight road and all the cities are located on this road itself. Concretely you can assume the road to be X-axis and and cities as points. So each city i is located at some integer distance xi from the beginning of road.
To provide wireless connection in each of the city, it is required to install some antennas at some point on the road. All the antennas currently available have same coverage range say R, so if an antenna is installed at a point x then it covers all cities that lie in the closed interval [x-R, x+R].
Given the position of all cities on the road, your task is to find the minimum number of antennas required to cover all the cities.
First line of input contains two space-separated integers, N and K. N is the number of cities and K is the coverage of any antenna as described in the problem statement. Next line contains a space-separated list of the positions of cities on road.
Print an integer which is the required answer for this task.
1 2 3
using namespace std;
int r= 2*t;
int count =1;
// If you find this blog somewhat helpful, please share it.......&.......Keep visiting..:)