From 1eb4dd320f868eea5b4a7e8c71a49336c3527f7d Mon Sep 17 00:00:00 2001 From: SUJAY GIJRE Date: Thu, 1 Jan 2026 12:53:29 -0500 Subject: [PATCH 1/2] Create Coin change 2 --- Coin change 2 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Coin change 2 diff --git a/Coin change 2 b/Coin change 2 new file mode 100644 index 00000000..b10fcbb7 --- /dev/null +++ b/Coin change 2 @@ -0,0 +1,30 @@ +Time complexity - O(nm) where n is number of coins and m is the amount +Space complexity - O(nm) + +class Solution { +public: + int change(int amount, vector& coins) { + int numberOfCoins=coins.size(); + + int matrix[numberOfCoins+1][amount+1]; + + for (int i=0;i<=amount;i++) { + matrix[0][i]=0; + } + for (int i=0;i<=coins.size();i++) { + matrix[i][0]=1; + } + + for (int i=1;i<=numberOfCoins;i++) { + for (int j=1;jj) { + matrix[i][j]=matrix[i-1][j]; + } else if (coins[i-1]<=j){ + matrix[i][j]=matrix[i-1][j] + matrix[i][j-coins[i-1]]; + } + } + } + return matrix[numberOfCoins][amount]; + + } +}; From c10aeb9e6a1fcfebbd52899522a4693e898d06ef Mon Sep 17 00:00:00 2001 From: SUJAY GIJRE Date: Thu, 1 Jan 2026 12:55:14 -0500 Subject: [PATCH 2/2] Create paint house --- paint house | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 paint house diff --git a/paint house b/paint house new file mode 100644 index 00000000..a172cebc --- /dev/null +++ b/paint house @@ -0,0 +1,33 @@ +// Time Complexity - O(3n) where n is the number of houses +// Space Complexity - O(3) +class Solution { +public: + int minCost(vector>& costs) { + int rows = costs.size(); + int cols = costs[0].size(); + + vector> dp(rows, vector(cols, 0)); + + for (int i=0;i