Skip to content

Commit f14edc1

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] clean code: variable naming
1 parent b4780c6 commit f14edc1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/count_triplets_1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from collections import Counter
55

66

7-
def count_triplets_brute_force(arr: list[int], r: int) -> int:
7+
def count_triplets_brute_force(arr: list[int], ratio: int) -> int:
88

99
size = len(arr)
1010
counter = 0
@@ -14,22 +14,22 @@ def count_triplets_brute_force(arr: list[int], r: int) -> int:
1414
for k in range(j + 1, size):
1515
print(arr[i], arr[j], arr[k])
1616

17-
if r * arr[i] == arr[j] and r * arr[j] == arr[k]:
17+
if ratio * arr[i] == arr[j] and ratio * arr[j] == arr[k]:
1818
counter += 1
1919

2020
return counter
2121

2222

23-
def count_triplets(arr, r):
23+
def count_triplets(arr: list[int], ratio: int) -> int:
2424
a_counter = Counter(arr)
2525
b_counter = Counter()
2626
triplets = 0
2727

2828
for i in arr:
29-
j = i // r
30-
k = i * r
29+
j = i // ratio
30+
k = i * ratio
3131
a_counter[i] -= 1
32-
if b_counter[j] and a_counter[k] and i % r == 0:
32+
if b_counter[j] and a_counter[k] and i % ratio == 0:
3333
triplets += b_counter[j] * a_counter[k]
3434
b_counter[i] += 1
3535

0 commit comments

Comments
 (0)