Skip to content

Commit

Permalink
requested changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
freakin23 committed Sep 20, 2024
1 parent c54233e commit 02c5a3d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions solutions/silver/ccc-Firehose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ public class Firehose {
static final int MAX_H = 1000;
static final int STREET_SIZE = 1000000;

static boolean possible(int length, int numHouses, int numHydrants, int[] houses) {
for (int i = 0; i < numHouses; i++) {
static boolean possible(int length, int numHydrants, int[] houses) {
for (int i = 0; i < houses.length; i++) {

// Number of fire hydrants that are needed.
int needed = 0;

// The house that we need to connect a fire hydrant to.
int start = houses[i];

for (int j = 1; j < numHouses; j++) {
for (int j = 1; j < houses.length; j++) {
// Address of house at index j.
int end = houses[(i + j) % numHouses];
int end = houses[(i + j) % houses.length];

/*
* If the distance between the start and end houses is greater than
Expand Down Expand Up @@ -148,7 +148,7 @@ public class Firehose {
int ans = -1;
while (left <= right) {
int mid = (left + right) / 2;
if (possible(mid, numHouses, numHydrants, houses)) {
if (possible(mid, numHydrants, houses)) {
right = mid - 1;
ans = mid;
} else {
Expand All @@ -172,18 +172,18 @@ MAX_H = 1000
STREET_SIZE = 1000000


def possible(length: int, num_houses: int, num_hydrants: int, houses: list) -> bool:
for i in range(num_houses):
def possible(length: int, num_hydrants: int, houses: list) -> bool:
for i in range(len(houses)):

# Number of fire hydrants that are needed.
needed = 0

# The house that we need to connect a fire hydrant to.
start = houses[i]

for j in range(1, num_houses):
for j in range(1, len(houses)):
# Address of house at index j.
end = houses[(i + j) % num_houses]
end = houses[(i + j) % len(houses)]

"""
If the distance between the start and end houses is greater than
Expand Down Expand Up @@ -218,7 +218,7 @@ r = STREET_SIZE
ans = -1
while l <= r:
m = (l + r) // 2
if possible(m, num_houses, num_hydrants, houses):
if possible(m, num_hydrants, houses):
r = m - 1
ans = m
else:
Expand Down

0 comments on commit 02c5a3d

Please sign in to comment.