[pull] master from keon:master by pull[bot] · Pull Request #42 · jaydave/algorithms · GitHub
Skip to content

[pull] master from keon:master#42

Open
pull[bot] wants to merge 34 commits into
jaydave:masterfrom
keon:master
Open

[pull] master from keon:master#42
pull[bot] wants to merge 34 commits into
jaydave:masterfrom
keon:master

Conversation

@pull

@pull pull Bot commented Feb 15, 2022

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot]

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

@pull pull Bot added the ⤵️ pull label Feb 15, 2022
aalekhpatel07 and others added 28 commits February 16, 2022 11:22
Invoke pytest as a python module rather than a standalone executable.
Its bugging me that CI workflow is failing because of a test for this function. This bug fix should bring green ticks back again. ;)
* attach documentation to method; add annotations

* add test case for list of integers

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
* refactor(pylint): unionfind/count_islands.py

improves pylint score from 3.71 to 10.00

fixes KTH-Software-Engineering-DD2480#2

* refactor(pylint): algorithms/search/*.py

improves pylint score from 5.83 to 10.00.

fixes KTH-Software-Engineering-DD2480#7

* feat: improving pylint score

* refactor dp.combination_sum: lint score from 5.42 to 9.13

* refactor(pylint): algorithms/graph/*.py

Improves pylint score from 5.51 to 9.96.

Score is lower than 10 due to duplication between maximum_flow_bfs.py
and maximum_flow_dfs.py. However, due to the educational nature of this
repo, keeping it as is will probably be benefitial as it reduces
complexity while reading (having to jump between files).

fixes KTH-Software-Engineering-DD2480#9

* refactor egg_drop, hosoya_triangle, min_cost_path and planting_trees

* feat: improving pylint score of one_sparse_recovery

* refactor: move tests from regex_matching to tests folder

* refactor: lint score from 4.27 to 9.46

a reason that lint score isn't 10.00 is that the module is called dp,
which in turn makes pylint raise invalid name for all files in dp.
I leave that as it is, since I don't want to mess with the current folder structure.

fixes #3

* Fix: Fixed lint error, lint value now aboe 8

* refactor: add docstring to misra, score 10

* fix (misra): add a newline

* refactor: add docstring for one_sparse, score 9.33

* wip: refactor (pylint): algorithms/maths/
wip: #4

* Fix: pylint is above 8 for tree

* refactor (pylint): algorithms/maths/
Finished improving pylint score for maths folder.
fixes: #4

* Fixed: comments

* fix: small intendation fix

Co-authored-by: ekorre1001 <skyever@hotmail.se>
Co-authored-by: Philip Salqvist <philipsalqvist@MacBook-Pro-som-tillhor-Philip.local>
Co-authored-by: psalqvist <63300368+psalqvist@users.noreply.github.com>
Co-authored-by: Kubha99 <1kunalbhatnagar@gmail.com>
Co-authored-by: mantaur <mark.spel.konto@live.se>
…h requested changes. (#861)

* initial commit

* initial commit!

* Added Kadane's Algorithm for max_contiguous_subsequence_sum problem!

* Update README.md

* Update max_contiguous_subsequence_sum.py

* Update max_contiguous_subsequence_sum.py

* fix #854
* Added num_perfect_squares

* Added final test for increased coverage

* Fix requested changes for issue #767.

Also improved documentation and added 1 test case.

* Doc update to clarify intent for issue #767

This documentation update clarifies the intent and order of each code piece.

Co-authored-by: unknown <ntomsic@kth.se>
Co-authored-by: ntomsic <ccyfzz@gmail.com>
Co-authored-by: Keon <kwk236@gmail.com>
Fix invalid test related to t.sort() vs sorted(t)
* "delete_fixup" optimization

* node_min.parent != node -> node_min.parent is not node
There is a small typo in algorithms/sort/heap_sort.py.

Should read `occurred` rather than `occured`.
Co-authored-by: rahulrameshan <rahulrameshan@qburst.com>
It looks like there is no need to create a copy, we can replace the new elements inplace.
)

also added a small unit test to ensure the algorithm is correct

fixes: #15

Co-authored-by: Philip Salqvist <philipsalqvist@MacBook-Pro-som-tillhor-Philip.local>
* Update binary_search.py

* Update first_occurrence.py
Added window sliding approach to find longest non repeating sub string
* added kosaraju's algorithm under /algorithms/graph

* added test case for /algorithms/graph/strongly_connected_component_kosaraju

---------

Co-authored-by: Rubal Singh <nbarubz@gmail.com>
* Initial commit for remove duplicates

* Made changes to readme and added test case
cpatel321 and others added 5 commits June 27, 2025 01:30
* Added the validate bst function

* Added the validate bst function

---------

Co-authored-by: Piyush Goel <piyushgoel@Piyushs-MacBook-Air-4.local>
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.