Skip to content

Commit e6eb579

Browse files
authored
Merge pull request #152 from BrianLusina/feat/algorithms-heaps
feat(algorithms, heaps): top k and kth largest
2 parents 6cb240c + 39a67e0 commit e6eb579

File tree

121 files changed

+704
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+704
-43
lines changed

DIRECTORY.md

Lines changed: 19 additions & 13 deletions

pystrings/longest_happy_string/README.md renamed to algorithms/heap/longest_happy_string/README.md

Lines changed: 18 additions & 18 deletions

pystrings/longest_happy_string/__init__.py renamed to algorithms/heap/longest_happy_string/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def longest_diverse_string(a: int, b: int, c: int) -> str:
2020
# Process the heap until it's empty or no valid character can be added
2121
while max_heap:
2222
# Pop the character with the highest remaining frequency
23-
count, character = heappop(max_heap)
24-
count = -count # Convert back to positive
23+
negative_count, character = heappop(max_heap)
24+
count = -negative_count # Convert back to positive
2525

2626
# Check if adding this character violates the "no three consecutive" rule
2727
if len(result) >= 2 and result[-1] == character and result[-2] == character:

pystrings/longest_happy_string/images/examples/longest_happy_string_example_1.png renamed to algorithms/heap/longest_happy_string/images/examples/longest_happy_string_example_1.png

File renamed without changes.

pystrings/longest_happy_string/images/examples/longest_happy_string_example_2.png renamed to algorithms/heap/longest_happy_string/images/examples/longest_happy_string_example_2.png

File renamed without changes.

pystrings/longest_happy_string/images/examples/longest_happy_string_example_3.png renamed to algorithms/heap/longest_happy_string/images/examples/longest_happy_string_example_3.png

File renamed without changes.

pystrings/longest_happy_string/images/solutions/longest_happy_string_solution_1.png renamed to algorithms/heap/longest_happy_string/images/solutions/longest_happy_string_solution_1.png

File renamed without changes.

pystrings/longest_happy_string/images/solutions/longest_happy_string_solution_10.png renamed to algorithms/heap/longest_happy_string/images/solutions/longest_happy_string_solution_10.png

File renamed without changes.

pystrings/longest_happy_string/images/solutions/longest_happy_string_solution_11.png renamed to algorithms/heap/longest_happy_string/images/solutions/longest_happy_string_solution_11.png

File renamed without changes.

0 commit comments

Comments
 (0)