Satish Kumar N
Aug 29, 2017 · 1 min read

Solution for HackerRank Problem in C# : Hackerland Radio Transmitters

Problem statement can be found here : https://www.hackerrank.com/challenges/hackerland-radio-transmitters

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution {
static void Main(String[] args) {
string[] tokens_n = Console.ReadLine().Split(‘ ‘);
int noOfHouse = Convert.ToInt32(tokens_n[0]);
int range = Convert.ToInt32(tokens_n[1]);
string[] x_temp = Console.ReadLine().Split(‘ ‘);
int[] x = Array.ConvertAll(x_temp,Int32.Parse);
noOfHouse = x.Max();
int towerCount = 1;
int maxRange = range * 2 + 1;
int noOfHousesLeft = noOfHouse — maxRange;
while (noOfHousesLeft > maxRange)
{
towerCount++;
noOfHousesLeft = noOfHousesLeft — maxRange;
}
if (noOfHousesLeft > 0)
towerCount++;
Console.WriteLine(towerCount);
}
}

)
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade