130 Commits
Author SHA1 Message Date
Christian Clauss 3dae007c74 More ruff rules ANN for type annotations (#15443) 2026-09-26 17:27:43 +02:00
SARATHI-78SARATHI-78Christian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1c2181944c Add evil_number algorithm in maths/special_numbers (#15388)
* Add evil_number algorithm in maths/special_numbers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: SARATHI-78 <sundarasarathi78@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-21 11:46:50 +02:00
aryandgandhi b006e4c4c6 Remove nth node from end of list (#9880)
* removed nth node

* added link to learn about algo

* Addressed PR feedback

* update bot comments

* update type

* new branch

* new branch

* latest updates with typing

* latest updates with typing
2026-09-21 08:38:32 +02:00
Dharshini_RSChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
aa38af81c9 fix:bucket count type (#15063)
* fix:bucket count type

* fixed TypeError

* Refine docstring and adjust return statement

Updated docstring for partition_liked_list method to clarify behavior. Changed return statement from None to None for consistency.

* Add script to map open PRs to modified files

This script lists all open pull requests in the current directory's git repository and maps each file touched by any open PR to its corresponding PR numbers. It outputs the results in GitHub-flavored Markdown format.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add noqa comments for subprocess calls

Add noqa comments to suppress specific linting warnings.

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-13 09:25:21 +02:00
Inesh Agarwalpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
bde91502db Add XOR Linked List implementation with doctests (#13699)
* Add XOR Linked List implementation with doctests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add XOR Linked List implementation with doctests

* Add XOR Linked List implementation with doctests

* Add XOR Linked List implementation with doctests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Refine docstring and variable comment in XOR linked list

Updated docstring for clarity and corrected 'ids' to 'IDs'.

* Refactor Node class to use dataclass

Refactor Node class to use dataclass for cleaner syntax.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-13 08:27:13 +02:00
Martin Oywa 0051e4eae2 Add partition_list in linked_list (#13325) 2026-09-13 08:12:23 +02:00
Martin Oywa b59e85983f Add find kth_element_from_end in linked_lists (#13322)
* Add find kth_element_from_end in linked-lists

* Update kth_element_from_end docstring

* Update kth_element_from_end k to position
2026-09-13 08:10:38 +02:00
priya-sundaram-dev 945b5ab9ee data_structures: add return type annotations (ANN201) (#15306)
Annotate the unambiguous, primitive/container-returning public methods
flagged by ruff ANN201 across data_structures/ (int/bool/float/list/dict
and one fluent self-return). Reduces ANN201 in this directory from 58 to 36.

Element-typed and sentinel-union returns (e.g. node .data getters,
dict|False in the Sudoku solver) are intentionally left for follow-up,
since they warrant generics/TypeVar or a type checker rather than a guess.

Refs #15296
2026-09-13 00:10:48 +02:00
Christian Clauss 0525ef5da8 ruff rule ANN202 missing-return-type-private-function (#15298)
* ruff rule ANN202 missing-return-type-private-function

* ruff rule ANN202 missing-return-type-private-function
2026-09-12 21:47:08 +02:00
Christian Clauss 0da45b148a ruff rule ANN204 missing-return-type-special-method (#15300) 2026-09-12 21:35:04 +02:00
Christian Claussandcclauss 7bd1e983c3 ruff rules RET for return statements (#15301)
* updating DIRECTORY.md

* ruff rules RET for return statements

---------

Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-12 21:33:52 +02:00
Christian Clauss 201c2fbed9 Add data_structures/linked_list/sorted_linked_list.py 2026-09-11 15:16:11 +02:00
Christian Clauss 37d41a773b Use dataclasses, use iter to remove print function
Refactor Node class to use dataclass for attributes and update iter_linked_list to yield node data. Remove print_linked_list function and update merge function to use direct comparison.
2026-09-11 10:55:32 +02:00
Hardik Pawar 9215334b42 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 7a569ce0f8 Fix doctests 2026-09-11 10:55:32 +02:00
Hardik Pawar d2eae4d707 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 49fdd2e847 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 2a7f02f561 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 98dc827aa9 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 5c847f358d Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 29223066d2 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar c2a419ea47 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar 010e902251 Fix type hint 2026-09-11 10:55:32 +02:00
Hardik Pawar 93675b67f7 Add return type hint 2026-09-11 10:55:32 +02:00
Hardik Pawar e5f92c73c1 Fix 2026-09-11 10:55:32 +02:00
Hardik Pawar e45663018c Fix comments 2026-09-11 10:55:32 +02:00
Hardik Pawar 21dfa5ad9f Add Merge Sort Linked List algorithm 2026-09-11 10:55:32 +02:00
BHUMIKA KADU✨kadubhumikapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
636dd57af7 Fix ty invalid assignment (#15222)
* Fix ty invalid assignment diagnostics

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix unused typing import

* Fix gradient accumulation type handling

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix automatic differentiation gradient dtype handling

---------

Co-authored-by: kadubhumika <kadubhumika@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-08 17:57:46 +02:00
MindaugasandMaxim Smolskiy d927d67c4a Update Linked List from sequence script to use doctests (#12766)
* Update comments for linked list script.

* Add doctests for the linked list script.

* Update from_sequence.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-08-24 17:48:59 +03:00
Christian Clauss cd3c3c3130 Various ruff fixes (#12821) 2025-07-06 01:35:29 +03:00
IsidroandMaxim Smolskiy 11a61d15dc Generic type hint in DDL (#12677)
* Generic type hint in DDL

Instead of forcing int

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-04-21 22:04:39 +03:00
Maxim Smolskiy 0c8cf8e987 Fix bug for data_structures/linked_list/doubly_linked_list_two.py (#12651)
* Fix bug for data_structures/linked_list/doubly_linked_list_two.py

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py
2025-04-02 10:23:55 +03:00
IsidroandMaxim Smolskiy baab802965 doubly linked list: add dataclass and typing (#12647)
* Node is a dataclass

* fix mypy errors

* LinkedList is a dataclass

* fix mypy errors

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

* Update doubly_linked_list_two.py

---------

Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-04-01 21:55:14 +03:00
Maxim Evtush a5aed92b4c fix: typo in data_structures/linked_list/from_sequence.py (#12584) 2025-02-20 23:09:01 +03:00
pre-commit-ci[bot]andpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> fc33c50593 [pre-commit.ci] pre-commit autoupdate (#12398)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0)
- [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-25 21:46:20 +01:00
1227haran 918fa8bb8a Optimized O(n) to O(1) (#11669) 2024-10-02 11:07:07 -07:00
Maxim SmolskiyandChristian Clauss 7b88e15b1c Enable ruff RUF007 rule (#11349)
* Enable ruff RUF005 rule

* Enable ruff RUF007 rule

* Fix

* Fix

* Fix

* Update sorts/bead_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sorts/bead_sort.py

* Revert "Update sorts/bead_sort.py"

This reverts commit b10e5632e4.

* Revert "Update sorts/bead_sort.py"

This reverts commit 2c1816bf10.

* Update sorts/bead_sort.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-20 16:20:27 +02:00
Maxim Smolskiyandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 53b2926704 Enable ruff PGH003 rule (#11345)
* Enable ruff PGH003 rule

* Fix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-02 21:29:34 +02:00
pre-commit-ci[bot]andpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> bc8df6de31 [pre-commit.ci] pre-commit autoupdate (#11322)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2)
- [github.com/pre-commit/mirrors-mypy: v1.8.0 → v1.9.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.8.0...v1.9.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-03-13 07:52:41 +01:00
pre-commit-ci[bot]pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
ed8d9209da [pre-commit.ci] pre-commit autoupdate (#11275)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.14 → v0.2.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.14...v0.2.0)

* Upgrade pyproject.toml

* Revert sudoku_solver.py RUF017 Avoid quadratic list summation

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2024-02-05 20:48:10 +01:00
Christian Claussandgithub-actions eb17fcf8f5 Use dataclasses in circular_linked_list.py (#10884)
* Use dataclasses in circular_linked_list.py

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-24 08:45:36 -04:00
Aqib Javid BhatandTianyi Zheng 30122062b9 Add Floyd's Cycle Detection Algorithm (#10833)
* Add Floyd's Cycle Detection Algorithm

* Add tests for add_node function

* Apply suggestions from code review

* Update floyds_cycle_detection.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-23 13:56:43 -04:00
Precious C. Jacobpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
c92e86bd79 Add tests to data_structures/linked_list/swap_nodes.py (#10751)
* Added doctests to the swap_nodes file under linkedlist data structure

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added doctests to the swap_nodes file under linkedlist data structure

* Added doctests to the swap_nodes file under linkedlist data structure

* Added doctests to the swap_nodes file under linkedlist data structure

* Update swap_nodes.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-22 01:33:49 +02:00
Christian Claussandgithub-actions 3f094fe49d Ruff pandas vet (#10281)
* Python linting: Add ruff rules for Pandas-vet and Pytest-style

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-11 14:30:02 -04:00
Christian Clauss 844270c6e9 Remove backslashes from is_palindrome.py (#10169)
@SaiHarshaK Fixes https://github.com/TheAlgorithms/Python/pull/10081#discussion_r1349651289
2023-10-10 06:42:07 +13:00
Sai Harsha KottapalliChristian ClaussHarsha Kottapallipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
12e8e9ca87 Add DocTests to is_palindrome.py (#10081)
* add doctest ut

* test complete

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* format

* ruff update

* cover line 154

* Update data_structures/linked_list/is_palindrome.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* use dataclass

* pre-commit fix

* Fix mypy errors

* use future annotations

---------

Co-authored-by: Harsha Kottapalli <skottapalli@microsoft.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-09 14:06:16 +02:00
Christian Clauss d0c54acd75 Use dataclasses in singly_linked_list.py (#9886) 2023-10-06 15:31:11 +13:00
Christian Claussandgithub-actions 5869fda742 print reverse: A LinkedList with a tail pointer (#9875)
* print reverse: A LinkedList with a tail pointer

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-06 10:55:13 +13:00
Tianyi Zhengandgithub-actions dfdd78135d Fix mypy errors in circular_linked_list.py and swap_nodes.py (#9707)
* updating DIRECTORY.md

* Fix mypy errors in circular_linked_list.py

* Fix mypy errors in swap_nodes.py

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-10-04 18:05:00 +02:00
Siddhant TotadeChristian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3fd3497f15 Add Comments (#9668)
* docs : add comment in circular_linked_list.py and swap_nodes.py

* docs : improve comments

* docs : improved docs and tested on pre-commit

* docs : add comment in circular_linked_list.py and swap_nodes.py

* docs : improve comments

* docs : improved docs and tested on pre-commit

* docs : modified comments

* Update circular_linked_list.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* docs : improved

* Update data_structures/linked_list/circular_linked_list.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/circular_linked_list.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/swap_nodes.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/swap_nodes.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/swap_nodes.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/swap_nodes.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update requirements.txt

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/circular_linked_list.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update circular_linked_list.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-04 11:25:26 +02:00