From f601e2250424d99e42b29ca1140e8c70a5de2a99 Mon Sep 17 00:00:00 2001 From: Ashish Kumar <108181303+ashish01012001@users.noreply.github.com> Date: Wed, 11 Oct 2023 07:16:06 +0530 Subject: [PATCH 1/2] Edited README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 953596d..b22f40e 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,8 @@ | Longest Valid Parentheses | [LeetCode](https://leetcode.com/problems/longest-valid-parentheses/) | [YouTube](https://www.youtube.com/watch?v=VdQuwtEd10M) | [Java](./codes/java/LongestValidParentheses.java) | | Rotate Image | [LeetCode](https://leetcode.com/problems/rotate-image/) | [YouTube](https://www.youtube.com/watch?v=Y72QeX0Efxw) | [Java](./codes/java/RotateImage.java) | | Substring with concatenation of all words | [LeetCode](https://leetcode.com/problems/substring-with-concatenation-of-all-words/) | [YouTube](https://www.youtube.com/watch?v=_MGzsJ0F8lE) | [Java](./codes/java/SubstringWithConcatenationOfAllWords.java) | -|Largest rectangular sub-matrix having sum divisible by k| [GFG](https://www.geeksforgeeks.org/largest-rectangular-sub-matrix-sum-divisible-k/) | [YouTube](https://www.youtube.com/watch?v=_MGzsJ0F8lE) | [Python](./codes/python/largest_rectangular_sub_matrix_sum_divisbl_by_k) | +|Largest rectangular sub-matrix having sum divisible by k| [GFG](https://www.geeksforgeeks.org/largest-rectangular-sub-matrix-sum-divisible-k/) | [YouTube](https://www.youtube.com/watch?v=_MGzsJ0F8lE) | [Python](./codes/python/largest_rectangular_sub_matrix_sum_divisbl_by_k) +|Combination Sum III |[LeetCode](https://leetcode.com/problems/combination-sum-iii/) |[Youtube](https://youtu.be/rP_K3WJnRR4?si=W1RUODPlWwOSvsnV) |[C++](./codes/cpp/combination_sum_iii.cpp) From 73bbe22c2af338b64593456451488363bf66118a Mon Sep 17 00:00:00 2001 From: Ashish Kumar <108181303+ashish01012001@users.noreply.github.com> Date: Wed, 11 Oct 2023 07:16:33 +0530 Subject: [PATCH 2/2] Added a new question combination sum iii --- codes/cpp/combination_sum_iii.cpp | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 codes/cpp/combination_sum_iii.cpp diff --git a/codes/cpp/combination_sum_iii.cpp b/codes/cpp/combination_sum_iii.cpp new file mode 100644 index 0000000..35f8572 --- /dev/null +++ b/codes/cpp/combination_sum_iii.cpp @@ -0,0 +1,41 @@ +#include +#include +using namespace std; + +void findProperSubSet(int k,int n,vector>&ans,vector&partAns,int l){ + if(k==0&&n<0) + return; + if(k==0&&n==0){ + ans.push_back(partAns); + return; + } + if(k==0&&n>0) + return; + for(int i=l;i<=9;i++){ + partAns.push_back(i); + findProperSubSet(k-1,n-i,ans,partAns,i+1); + partAns.pop_back(); + } + + } +vector> combinationSum3(int k, int n) { + vector>ans; + vectorpartAns; + findProperSubSet(k,n,ans,partAns,1); + return ans; +} +int main() +{ + int k,n; + cin>>k; + cin>>n; + vector>ans=combinationSum3(k,n); + for(int i=0;i