Commit Graph

87 Commits

Author SHA1 Message Date
realstealthninja
a16a4bc9e8 fix: use const vector& instead of array 2024-10-04 20:48:48 +05:30
realstealthninja
1c2e186369 fix: vla in lisnlogn 2024-10-04 20:36:21 +05:30
realstealthninja
77e7ebadb4 fix: int overflow in floyd_warshall 2024-10-04 20:31:09 +05:30
realstealthninja
a0abcbe496 fix: vla in longest_common_subsequence 2024-10-04 20:25:25 +05:30
realstealthninja
2b278e9618 feat: remove kadane and replace it with kadane2 2024-10-04 19:59:52 +05:30
realstealthninja
4db1f400da fix: vla in floyd_warshall 2024-10-04 19:58:10 +05:30
realstealthninja
f7154b70e8 fix: vla in edit_distance 2024-10-04 19:53:17 +05:30
realstealthninja
94ca2dffba fix: vla in coin_change 2024-10-04 19:49:50 +05:30
realstealthninja
3091f1502c fix: vla in egg_dropping_puzzel 2024-10-04 19:49:39 +05:30
realstealthninja
b796161327 fix: vla in floyd_warshall 2024-10-04 19:49:25 +05:30
realstealthninja
efea5c64b1 fix dynamic array in egg_dropping puzzle 2024-10-01 23:13:49 +05:30
realstealthninja
7984cd41c8 fix: dynamic array in coin_change 2024-10-01 23:11:46 +05:30
realstealthninja
c7064a632f fix: typo in word_break 2024-10-01 23:11:28 +05:30
realstealthninja
7da9561581 fix: typo in bellman_ford 2024-10-01 22:46:57 +05:30
realstealthninja
48f03b23b8 fix: memory leak in bellman_ford 2024-10-01 22:44:55 +05:30
realstealthninja
8d260bf328 fix: add <set> header to longest increasing subsequence nlogn 2024-10-01 22:07:16 +05:30
realstealthninja
a71fa6d02f fix: compilation error in catalan numbers 2024-10-01 22:05:00 +05:30
realstealthninja
8ed74c6409 fix: add an include for functional in catalan_numbers 2024-10-01 21:24:36 +05:30
realstealthninja
939ca4a6a1 fix: init of transform_reduce in dynamic_programming 2024-10-01 21:20:36 +05:30
realstealthninja
79dd912cd1 fix: add cmakelists to dynamic programming 2024-10-01 20:59:58 +05:30
Piotr Idzik
f789e3bb9e style: cleanup catalan_numbers.cpp (#2740)
* style: cleanup `catalan_numbers.cpp`

* docs: update file level docs

* style: use `std::transform_reduce`
2024-09-29 19:24:02 +05:30
SOZEL
9702903a12 Implement Trapped RainWater (#2716)
* chore: add `trapped_rainwater.cpp` to DIRECTORY.md

* feat: implement Trapped Rain Water algorithm

* chore: add links to the trapped rain water problem

* chore(docs): remove Trapped Rain Water dir

* ref: add edges tests

* doc: adding Sozel as author

* doc: includes documentatino

* ref: use `unsigned int` for height of walls

* fix: use fixed-width integers instead of unsigned int

* chore: rearrange included libraries

---------

Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
2024-08-31 15:08:24 +05:30
David Leal
7003ba83ea feat: improve the Armstrong Number algorithm (#2480)
Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
2023-07-19 14:33:55 -06:00
Piotr Idzik
32db99c1de [fix/docs]: cleanup longest_common_string.cpp (#2462)
* updating DIRECTORY.md

* fix: cleanup longest_common_string.cpp

* clang-format and clang-tidy fixes for 3280d46e

* docs: explain why utility header is needed

* refactor: add test_all()

* docs: add relevant doc-strs

* refactor: rename to tests()

* style: typo fix

* style: use string instead of str

* Apply suggestions from code review

The code after this commit requires reformatting.

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 18203b20

* style: give an exact reason why iostream is needed

* style: make all test functions `static`

* docs: update missing docs

* chore: apply suggestions from code review

---------

Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2023-07-03 23:40:35 -06:00
David Leal
4f4585d4c1 docs: improve longest_palindromic_subsequence.cpp (#2467) 2023-05-19 19:22:54 -06:00
Piotr Idzik
4fc14710b6 fix: segv in longest_palindromic_subsequence.cpp (#2461)
* fix: initialise properly res, set properly size of ans

* test: add check with empty input

* style: use const reference as input type

* refactor: add ind_type

* style: use reverse interators to b

* style: use auto in definition of idx

* updating DIRECTORY.md

* style: clean-up includes

* style: use std::string::size_type in definition of ind_type

---------

Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2023-05-18 11:26:06 -06:00
Suman Mondal
0f20cdcf8f feat: add maximum circular subarray sum (#2242)
* Create maximum_circular_subarray.cpp

* Delete maximum_circular_subarray.cpp

* Create maximum_circular_subarray.cpp

* Update maximum_circular_subarray.cpp

Used the template provided.

* updating DIRECTORY.md

* Update maximum_circular_subarray.cpp

* Update maximum_circular_subarray.cpp

* Update maximum_circular_subarray.cpp

* Update maximum_circular_subarray.cpp

* Update maximum_circular_subarray.cpp

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update maximum_circular_subarray.cpp

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/maximum_circular_subarray.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update maximum_circular_subarray.cpp

Fixed the comments according to @krishnacx

* chore: apply suggestions from code review

---------

Co-authored-by: Suman Mondal <94859440+sumanarlert@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2023-02-06 14:11:52 -06:00
Ashish Bhanu Daulatabad
5b238724b8 feat: add Strassen's Matrix Multiplication (#2413)
* Feat: Add Strassen's matrix multiplication

* updating DIRECTORY.md

* Fix cpp lint error

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for 02439b57

* Fix windows error

* Add namespaces

* updating DIRECTORY.md

* Proper documentation

* Reduce the matrix size.

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for 0545555a

Co-authored-by: toastedbreadandomelette <toastedbreadandomelette@gmail.com>
Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2023-01-24 14:03:06 -06:00
KillerAV
a6a9d8e75a feat: add Subset Sum (#2020)
* Create subset_sum.cpp

* Update subset_sum.cpp

Lint formatting.

* chore: apply suggestions from code review

* chore: apply suggestions from code review

* fix: CI issues

Co-authored-by: David Leal <halfpacho@gmail.com>
2023-01-24 13:55:55 -06:00
aadarshkt
ee9835378f docs: fix grammatical errors and typos (#2201)
* docs: fix grammatical errors and typos

* compilation error fixed

* Revert "compilation error fixed"

This reverts commit 0083cbfd1a.
2022-10-18 16:02:47 -05:00
Daemon
f0b35b657a chore: fix Markdown formatting in dynamic_programming/kadane2.cpp (#2276) 2022-10-16 23:02:37 -05:00
Lajat5
5147306db3 feat: Added Solution of Partition Problem (#1842)
* Create partition_problem.cpp

* Fix #1

* Fix #2

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for 3b8dbf00

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for a152bf75

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 1c057113

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for baf20a6f

* Update dynamic_programming/partition_problem.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 749d9337

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2021-11-14 10:55:54 -06:00
Anuran Roy
85721be69b feat: Modify search/text_search.cpp (#1662)
* Modified search/text_search.cpp

* Added tests

* Added a few test cases

* Added a few more test cases and documentation

* Minor fix

* Minor fixes

* Minor fixes

* Minor output fixes

* Minor output fixes

* Minor readability fixes

* clang-format and clang-tidy fixes for a01765a6

* Restored original settings

* clang-format and clang-tidy fixes for 6a8f3a4e

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2021-10-14 13:34:55 -05:00
Harsh Tripathi
89bfc1244e fix: Armstrong number bug fixes (#1689)
* added a new directory named Recursion and a most common exxample of recusion i.e. Tower of Hanoi in it

* Added Comments

* Bug fixed according to the correct definition of armstrong_number

* Bug Fixed in armstrong_number.cpp

Bug Fixed in armstrong_number.cpp according to the correct definition of armstrong_number.

* Update armstrong_number.cpp

* Added documentation

* Delete Recursion directory

* Update armstrong_number.cpp

* Update dynamic_programming/armstrong_number.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update armstrong_number.cpp

fixed errors.

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Update armstrong_number.cpp

Applied suggested changes.

* Update armstrong_number.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>
2021-10-13 11:19:09 -05:00
Swastika Gupta
6115bc2981 feat: Add House Robber algorithm (#1524)
* Create house_robber.cpp

* updating DIRECTORY.md

* Update dynamic_programming/house_robber.cpp

Co-authored-by: Abhinn Mishra <49574460+mishraabhinn@users.noreply.github.com>

* Update dynamic_programming/house_robber.cpp

Co-authored-by: Abhinn Mishra <49574460+mishraabhinn@users.noreply.github.com>

* Update dynamic_programming/house_robber.cpp

Co-authored-by: Abhinn Mishra <49574460+mishraabhinn@users.noreply.github.com>

* clang-format and clang-tidy fixes for c00823e8

* Update house_robber.cpp

* clang-format and clang-tidy fixes for cdf701c2

* Update house_robber.cpp

* clang-format and clang-tidy fixes for 39c3719f

* Update dynamic_programming/house_robber.cpp

Co-authored-by: Abhinn Mishra <49574460+mishraabhinn@users.noreply.github.com>

* clang-format and clang-tidy fixes for 126e3f21

* Update house_robber.cpp

* Update dynamic_programming/house_robber.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/house_robber.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/house_robber.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/house_robber.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update house_robber.cpp

* clang-format and clang-tidy fixes for 474a5f0b

* Update dynamic_programming/house_robber.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/house_robber.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 203cce31

* Update house_robber.cpp

* Update house_robber.cpp

* Update house_robber.cpp

* clang-format and clang-tidy fixes for 6b0bea93

* Apply suggestions from code review

* Apply suggestions from code review

* clang-format and clang-tidy fixes for 913baf88

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Abhinn Mishra <49574460+mishraabhinn@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2021-07-09 14:02:28 -05:00
David Leal
554919d9f5 [feat/fix/docs]: Improve the dynamic_programming/longest_increasing_subsequence.cpp file (#1504)
* [feat/fix/docs]: Improve the `dynamic_programming/longest_increasing_subsequence.cpp` file

* [test/feat]: Add self-test implementations and...

...namespace (`dynamic_programming`).
Thanks to @manncodes for the idea and help!

Co-authored-by: Mann Patel <manncodes@users.noreply.github.com>

* clang-format and clang-tidy fixes for 7d4562d6

Co-authored-by: Mann Patel <manncodes@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-06-18 14:17:31 -05:00
Nirjas Jakilim
c854b78bc9 feat: Added Minimum Edit Distance Algorithm (#1472)
* Added Minimum Edit Distance Algorithm

* Updated the code According to the guidelines

* Updated with necessary changed and documentation

* fix: Apply suggestions from code review

* updating DIRECTORY.md

* Some more chnages according to clang-tidy

clang-tidy suggested moving all if-else statements under braces. So, I did it.

* Array changed to vector as suggested

Using of arrays changed to vectors as clang-tidy suggested to use vector instead of arrays.

* Apply suggestions from code review

Co-authored-by: David Leal <halfpacho@gmail.com>

* Updated with necessary changes

* Apply suggestions from code review

Co-authored-by: David Leal <halfpacho@gmail.com>

* Slight fixes on a comment

* Updated Necessary Changes

* Apply suggestions from code review

Co-authored-by: David Leal <halfpacho@gmail.com>

* Updated with necessary changes

* Updated with necessary changes

* Updated with changes

* Updated with changes and some tweaks

* Updated with changes

* Update dynamic_programming/minimum_edit_distance.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/minimum_edit_distance.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Updated suggested changes

Co-authored-by: David Leal <halfpacho@gmail.com>

Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Anup Kumar Panwar <1anuppanwar@gmail.com>
2021-04-12 16:04:13 +05:30
Ashish Bhanu Daulatabad
a2970af4c4 feat: add abbreviation.cpp: topic: Dynamic Programming (#1461)
* Feat: Abbreivation problem (abbreviation.cpp), topic: Dynamic Programming.

* Spelling correction

* Spelling Mistakes

* Refactoring code

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for 232d4f5e

* clang-format and clang-tidy fixes for 232d4f5e

* Documentation and renaming variable

* adding a comment

* adding a comment

* Re-documentation

* Re-documentation

* Re-documentation

* Update dynamic_programming/abbreviation.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/abbreviation.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/abbreviation.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Varaible type-checks

* Update dynamic_programming/abbreviation.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 8f5a50be

* Varaible type-checks

* Markdown correction

* Comment Modification

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2021-03-12 00:33:15 +05:30
anjali1903
ade6010d11 feat: add longest palindromic subsequence algorithm (#1185)
* feat: add longest palindromic subsequence algorithm

* feat: add longest palindromic subsequence algorithm

* feat: add longest palindromic subsequence algorithm

* feat: add longest palindromic subsequence algorithm
2021-02-05 15:16:06 +05:30
Ayaan Khan
9820c9cc91 Merge pull request #1388 from ABHISHEK-821005/master
fix: updated datatypes references
2021-02-02 23:57:14 +05:30
Kaustubh Damania
67e26cfbae feat: Add ncr mod p code (#1325)
* feat: Add ncr mod p code (#1323)

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Added all functions inside a class + added more asserts

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for f6df24a5

* Replace int64_t to uint64_t + add namespace + detailed documentation

* clang-format and clang-tidy fixes for e09a0579

* Add extra namespace + add const& in function arguments

* clang-format and clang-tidy fixes for 8111f881

* Update ncr_modulo_p.cpp

* clang-format and clang-tidy fixes for 2ad2f721

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 5b69ba5c

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for a8401d4b

Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-22 23:05:01 +05:30
ABHISHEK-821005
2cc9100f83 added a new example to check correctness of the code 2020-10-31 11:53:40 +05:30
ABHISHEK-821005
6556e0da3c Update cut_rod.cpp 2020-10-31 11:46:30 +05:30
webdesignbydivyansh
7b92e8d625 feat: Coin Change Problem (#1378)
* palindrome no

a program to check if a number is palindrome or not

* updated palindrome.cpp

* updated palindrome.cpp

missing equal to operator at line no 16

* flatten_a_binary_seach_tree

This program flattens a binary search tree or in simple words, converts it into linked list in sorted form

* a prog to convert bst into linked list

A code that is used to convert a binary search tree into linked list

* created merge k sorted arrays

this program displays all the elements from the different arrays(sorted) into 1 single array(sorted).

* updated braces in some parts

* included braces in line no 58

* included braces in line 58 and 60

* created trap_rainwater.cpp

A program to calculate the maximum amount of water that can be stored between buildings.

* deleted rainwater harvesting

* deleted palindrome

* deleted merge k sorted arrays

* deleted binary search tree to linked list

* deleted binary search tree to linked list

* created min_coins_topdown.cpp

This is another version of coins exchange problem solved using top down approach

* updated the code

please take a look at it

* final changes

* updated my code

* updating DIRECTORY.md

* changed int64_t to int8_t and int16_t

* edited line 3

* changed line 3

* edited line 3 & removed line 18

* added extra space

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-31 11:42:24 +05:30
ABHISHEK-821005
063e36922b updated references 2020-10-30 19:06:04 +05:30
ABHISHEK-821005
b76e41bf2e added a new function to improve time complexity
WhatIfAllPricesAreSame(price1,n1) added this function.
2020-10-28 17:53:40 +05:30
ABHISHEK-821005
e272befbd7 updated time complexity
if all the prices are same case(o(n)).
2020-10-26 12:51:34 +05:30
Sujay008
57a5dcb2c7 feat: add palindrome partitioning algorithm (#1319)
* feat: add palindrome partitioning algorithm

* Update palindrome_partitioning.cpp

* updating DIRECTORY.md

* Update palindrome_partitioning.cpp

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-25 13:21:24 -06:00
ABHISHEK-821005
c19b4896c1 improved time complexity
if all the price are same then we can do it in o(n).
improved time complexity.
2020-10-25 20:55:58 +05:30
Pardeep Bhatt
3206660bcd added documentation in dynamic_programming/0_1_knapsack.cpp (#1207)
* added docs

* algorithm added in comments

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>

* updated template parameter

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update dynamic_programming/0_1_knapsack.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

Co-authored-by: Krishna Vedala <7001608+kvedala@users.noreply.github.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2020-10-18 13:23:56 -05:00