Skip to content

[pull] master from keon:master#36

Merged
pull[bot] merged 1 commit intods-ebooks:masterfrom
keon:master
Nov 3, 2025
Merged

[pull] master from keon:master#36
pull[bot] merged 1 commit intods-ebooks:masterfrom
keon:master

Conversation

@pull
Copy link

@pull pull bot commented Nov 3, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

* Optimize remove_duplicates from O(n²) to O(n) time complexity

Use a set for O(1) membership checks instead of checking membership in a list which is O(n). This reduces the overall time complexity from O(n²) to O(n).

Added documentation for time and space complexity.

Co-Authored-By: Keon <kwk236@gmail.com>

* Fix: Handle unhashable items in remove_duplicates

The previous optimization broke when the function received unhashable items
like lists or dicts, causing TypeError. This commit adds backward compatibility
by checking if items are hashable:
- Hashable items use set for O(1) lookup (fast path)
- Unhashable items fall back to list membership check (preserves original behavior)

This maintains the O(n) optimization for the common case while preserving
backward compatibility for all input types.

Co-Authored-By: Keon <kwk236@gmail.com>

* Fix: Apply black formatting to remove_duplicates.py

Add blank lines after imports and before function definition to comply
with black code formatting style, which is checked by CI.

Co-Authored-By: Keon <kwk236@gmail.com>

* Fix: Remove unused nonlocal/global declarations (F824 errors)

Remove unused nonlocal declarations in find_all_cliques.py and unused
global declaration in construct_tree_postorder_preorder.py to fix
flake8 F824 errors that were causing CI to fail.

These declarations were unnecessary because:
- In find_all_cliques: compsub and solutions are only mutated (append/pop),
  not reassigned, so nonlocal is not needed
- In construct_tree: pre_index is never used or assigned in this function,
  only in construct_tree_util

Also applied black formatting to both files.

Co-Authored-By: Keon <kwk236@gmail.com>

* Fix: Resolve pre-existing test failures blocking CI

Fix two pre-existing test failures that were causing CI to fail:

1. test_remove_duplicates: Added missing expected values to assertListEqual
   calls. The test was malformed with only input arrays but no expected
   outputs, causing TypeError.

2. test_summarize_ranges: Fixed summarize_ranges() to return tuples
   instead of strings. The function was converting tuples to formatted
   strings like '0-2', but tests expected tuples like (0, 2).

Both fixes align implementations with test expectations and docstrings.
Applied black formatting to both files.

Co-Authored-By: Keon <kwk236@gmail.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Keon <kwk236@gmail.com>
@pull pull bot locked and limited conversation to collaborators Nov 3, 2025
@pull pull bot added the ⤵️ pull label Nov 3, 2025
@pull pull bot merged commit 5991e05 into ds-ebooks:master Nov 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants