Given a map of the city and the network range, the task is to determine the minimum number of the tower so that every house is within range of at least one tower. Each tower must be installed on top of an existing house.
Input: range : 1 house : 1 2 3 4 5 Output: 2 Input: range : 2 house : 7 2 4 6 5 9 12 11 Output: 3
All cities can be covered by inserting 2 towers i.e. at house 2 and 4.
All cities can be covered by inserting 3 towers i.e. at house 4, 9 and 12.
- First, sort all the element.
- Count only once and then traverse till its middle house.
- After this again traverse till tower range.
- Again repeat 1, 2, 3 step till all the houses are covered.
Below is the implementation of above approach:
Time Complexity: O(nlogn)
Space Complextity: O(1)
- Minimum number of swaps required to sort an array of first N number
- Minimum number of operations required to reduce N to 1
- Minimum number of changes required to make the given array an AP
- Minimum number of swaps required to sort an array | Set 2
- Minimum deletions required such that any number X will occur exactly X times
- Minimum number of days required to complete the work
- Minimum number of swaps required to sort an array
- Minimum number of bottles required to fill K glasses
- Minimum number of segments required such that each segment has distinct elements
- Minimum number of swaps required for arranging pairs adjacent to each other
- Find out the minimum number of coins required to pay total amount
- Minimum number of given operations required to reduce the array to 0 element
- Minimum number of Circular obstacles required to obstruct the path in a Grid
- Minimum Number of Platforms Required for a Railway/Bus Station | Set 2 (Map based approach)
- Find the minimum number of operations required to make all array elements equal
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.