Commit Graph

440 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
716bdeb68b
[pre-commit.ci] pre-commit autoupdate (#11473)
* [pre-commit.ci] pre-commit autoupdate

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)

* Fix ruff issues

* Fix ruff issues

---------

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-07-02 07:02:29 +02:00
Marco-campione-github
b8afb214f8
Changed the N to self.N in show_data in segment_tree.py (#11276) 2024-05-31 01:11:09 -07:00
Maxim Smolskiy
c599f6c910
Fix some SIM114 per file ignores (#11395)
* updating DIRECTORY.md

* Fix some SIM114 per file ignores

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

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

* Fix review issue

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-10 21:59:53 +02:00
Maxim Smolskiy
5131e3145d
Fix some ARG002 per file ignores (#11382)
* Fix some ARG002 per file ignores

* Fix

* updating DIRECTORY.md

* Fix review issue

* Fix review issue

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
2024-05-01 21:27:59 +02:00
Maxim Smolskiy
2d6be5fbb0
Enable ruff UP031 rule (#11388) 2024-04-30 06:40:26 +02:00
Maxim Smolskiy
4700297b3e
Enable ruff RUF002 rule (#11377)
* Enable ruff RUF002 rule

* Fix

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-22 21:51:47 +02:00
Maxim Smolskiy
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 Smolskiy
a42eb35702
Enable ruff E741 rule (#11370)
* Enable ruff E741 rule

* [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-04-19 21:30:22 +02:00
Jiayou Qin
9e55c9d984
Added documentations (#11352)
* Added documentations

* Update data_structures/queue/circular_queue.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-08 13:35:22 +02:00
Maxim Smolskiy
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
Maxim Smolskiy
f5bbea3776
Enable ruff RUF005 rule (#11344) 2024-04-02 21:18:47 +02:00
Maxim Smolskiy
f437f92279
Enable ruff INP001 rule (#11346)
* Enable ruff INP001 rule

* Fix

* Fix

* Fix

* Fix

* Fix
2024-04-02 21:13:56 +02:00
Maxim Smolskiy
93fb555e0a
Enable ruff SIM102 rule (#11341)
* Enable ruff SIM102 rule

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

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

* Fix

* [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-04-02 03:27:56 +02:00
Maxim Smolskiy
39daaf8248
Enable ruff RUF100 rule (#11337) 2024-04-01 21:36:41 +02:00
Maxim Smolskiy
516a3028d1
Enable ruff PLR5501 rule (#11332)
* Enable ruff PLR5501 rule

* [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-28 18:25:41 +01:00
MrBubb1es
19fd435042
Improved doctests for some functions (#11334) 2024-03-28 18:19:51 +01:00
pre-commit-ci[bot]
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]
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
Suyash Dongre
05a5cdacc3
Added doctest to skew_heap.py (#11147)
* Added doctest to skew_heap.py

* Update skew_heap.py

* Update data_structures/heap/skew_heap.py

Co-authored-by: Saptadeep Banerjee  <69459134+imSanko@users.noreply.github.com>

* Update skew_heap.py

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

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

* Update skew_heap.py

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

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

---------

Co-authored-by: Saptadeep Banerjee <69459134+imSanko@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-18 13:39:27 +01:00
Ataf Fazledin Ahamed
0101dd42dc
Fixed Inappropriate Logical Expression (#11203)
Signed-off-by: fazledyn-or <ataf@openrefactory.com>
2024-01-16 09:43:33 +01:00
Indrajeet Mishra
b46fc1de04
Corrected the Python Doctest command in equilibrium_index_in_array.py script (#11212)
Co-authored-by: Indrajeet Mishra <indrajeetmishra@thecoddiwompler.local>
2023-12-20 00:05:27 +01:00
Suyash Dongre
84a1533fd5
Added doctest to binary_search_tree.py (#11145)
* Added doctest to binary_search_tree.py

* Apply suggestions from code review

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-11-25 15:29:44 +01:00
Suyash Dongre
0e2e6abd6f
Added doctest to heap.py (#11129)
* Added doctest to heap.py

* Update heap.py
2023-11-13 17:05:22 +06:00
Suyash Dongre
fb17eeab7d
Added doctest to stack.py (#11149) 2023-11-11 21:16:43 -05:00
Suyash Dongre
8b7352626e
Added doctest to randomized_heap.py (#11151) 2023-11-11 21:13:04 -05:00
Sunny Kumar
eb989c08cd
Data structures/arrays/triplet sum (#11134)
* updated code for find triplets with 0 sum

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* extra line added at the end of file

Signed-off-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>

* extra line added at the end of file

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

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

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

* file updated with comments

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* updated the comments as suggested by community

Signed-off-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>

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

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

* file updated according to community comments

Signed-off-by: Skyad <777.sunnykumar@gmail.com>

* Update find_triplets_with_0_sum.py

---------

Signed-off-by: Skyad <777.sunnykumar@gmail.com>
Signed-off-by: Sunny Kumar <sunny.kumar09@ad.infosys.com>
Co-authored-by: Sunny Kumar <sunny.kumar09@ad.infosys.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-11-06 18:10:50 +06:00
Suyash Dongre
1e50cf3660
Added doctest to binary_search_tree.py (#11141)
* Added doctest to binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-11-05 14:23:39 +05:45
Suyash Dongre
ebfdb127e7
Added doctest to hash_map.py (#11105)
* Added doctest to heap.py

* Added doctest to hash_map.py

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

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

* Update hash_map.py

* Added doctest to hash_map.py

* Added doctest to hash_map.py

* Added doctest to detecting_english_programmatically.py

* Update detecting_english_programmatically.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-11-04 17:49:57 +05:45
dekomori_sanae09
c38b222212
serialize deserialize binary tree (#9625)
* added serialize and desrialize bin tree

* format files

* added type hints

* added type hints

* Use dataclass .__eq__(), .__iter__(), and .__repr__()

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-30 00:07:21 +01:00
Suyash Dongre
67c85ee289
Added doctest to hash_map.py (#11082)
* Added doctest to heap.py

* Added doctest to hash_map.py

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

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

* Update hash_map.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-29 17:01:54 +01:00
Suyash Dongre
b51b833e0a
Added doctest to heap.py (#11059) 2023-10-28 21:43:20 +02:00
Khushi Shukla
185a35589a
Create monotonic_array.py (#11025)
* Create monotonic_array.py

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

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

* Update monotonic_array.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-27 12:42:34 -04:00
Suyash Dongre
f336cca8f8
Added doctest to double_hash.py (#11020)
* Added doctest to double_hash.py

* Update double_hash.py
2023-10-27 12:40:42 -04:00
Suyash Dongre
34eb9c529a
Added doctest to hash_table.py (#11023)
* Added doctest to hash_table.py

* Update hash_table.py

* Update hash_table.py

* Update hash_table.py

* Update hash_table.py

* Apply suggestions from code review

* Update hash_table.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-27 14:36:43 +02:00
Suyash Dongre
fe4aad0ec9
Added doctest & docstring to quadratic_probing.py (#10996)
* Added doctest & docstring to quadratic_probing.py

* Update quadratic_probing.py

* Update quadratic_probing.py
2023-10-26 17:21:45 +02:00
Ed
a8dfd403f6
Add new algorithm index_2d_array_in_1d (#10973)
* Add new algorithm index_2d_array_in_1d

* Add doctest for iter function

* The power of dataclasses

* Update index_2d_array_in_1d.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-26 16:33:42 +02:00
Suyash Dongre
29b8ccdc2f
Added doctest to hash_table.py (#10984) 2023-10-26 14:12:28 +02:00
Neha
6497917352
Added Kth largest element algorithm (#10687)
* neha3423

* neha3423

* neha3423

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

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

* neha3423

* neha3423

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

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

* neha323

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

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

* neha3423

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

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

* neha3423

* neha3423

* neha3423

* neha3423

* Added test case for tuple

* Update kth_largest_element.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-26 10:54:30 +02:00
AdityaAtoZ
3d0a409ce1
Improved Equilibrium Index of an Array. (#10899)
* Improved Equilibrium Index of an Array.

This is the modifications made to the original code:

1. Create Doctest Instructions: Python "doctest" can be executed by running the following command: python -m doctest -v equilibrium_index.py.

2. Deleted Argument {size}: Deleted the `size` argument because `len(arr)} allows the array's length to be determined inside the function, simplifying and improving the readability of the function signature.

3. Used {enumerate}: To improve code readability and indicate that we're working with element-index pairs, we iterated through the array using both elements and their indices using the `enumerate` function.

4. Optimized the Loop: To prevent pointless additions, the loop was improved by initializing {left_sum} with the value of the first element (arr[0]). Furthermore, since the beginning and last items (0 and size - 1) cannot be equilibrium indices, there is no need to check them, saving further computations.

* [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>
2023-10-25 16:33:35 -04:00
Christian Clauss
c2c6cb0f5c
Add dataclasses to binary_search_tree.py (#10920) 2023-10-25 16:28:23 -04:00
Christian Clauss
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
Gourav Raj
481aff7928
Add Mirror a Binary Tree solution (#9534)
* Add `Invert a Binary Tree` solution

* Add type

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

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

* Add `doctest`

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

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

* Add `test` to `get_tree_inorder`

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

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

* Add `test` changes

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

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

* Fix lint errors

* Fix precommit errors

* Update and rename invert_binary_tree.py to mirror_binary_tree.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-24 09:54:38 +02:00
Aqib Javid Bhat
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. Jacob
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 Clauss
26ffad9d17
Simplify is_bst.py (#10627)
* Simplify is_bst.py

* updating DIRECTORY.md

* Update is_bst.py

* Rename is_bst.py to is_sorted.py

* updating DIRECTORY.md

* Update data_structures/binary_tree/is_sorted.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2023-10-19 13:31:51 -04:00
Anubhavpandey27
09c2b2d006
Add arrays/sudoku_solver.py (#10623)
* Create Sudoku_Solver

Each of the digits 1-9 must occur exactly once in each row.
Each of the digits 1-9 must occur exactly once in each column.
Each of the digits 1-9 must occur exactly once in each of the 9 3x3 sub-boxes of the grid.
The '.' character indicates empty cells.

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

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

* Rename Sudoku_Solver to sudoku_solver.py

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

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

* Update sudoku_solver.py

* [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>
2023-10-17 19:07:40 +02:00
aryandgandhi
b5786c87d8
update segmenttree docstrings Fixes #9943 (#9975)
* update docstrings

* update docstrings

* update docstrings
2023-10-17 03:25:07 +02:00
Adarsh Sidnal
fcea18c9f0
Added an algorithm transfrom bst to greater sum tree (#9777)
* Added an algorithm transfrom bst to greater sum tree

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

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

* Update and rename transform_bst_sum_tree.py to is_sum_tree.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-17 00:56:14 +02:00
halfhearted
1e468c1028
Floor and ceil in Binary search tree added (#10432)
* earliest deadline first scheduling algo added

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

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

* earliest deadline first scheduling algo added

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

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

* ceil and floor and bst

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

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

* ceil and floor and bst 2

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

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

* ceil and floor and bst 3

* Update and rename floor_ceil_in_bst.py to floor_and_ceiling.py

* Delete scheduling/shortest_deadline_first.py

---------

Co-authored-by: ArunSiva <Arunsiva003@users.noreply.github.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-16 19:12:33 +02:00
Vinayak Upadhyay
778e2010d6
Added functionality to calculate the diameter of given binary tree (#10526)
* Added code to find diameter of given binary tree

* Modified diameter_of_binary_tree file

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

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

* Update diameter_of_binary_tree.py

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

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

* Update diameter_of_binary_tree.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-16 18:46:44 +02:00