diff --git a/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stock atmost B times.cpp b/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stock atmost B times.cpp new file mode 100644 index 0000000..e93ba92 --- /dev/null +++ b/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stock atmost B times.cpp @@ -0,0 +1,30 @@ +#include "bits/stdc++.h" +using namespace std; + +int solve(vector &prices, int k) +{ + int n = prices.size(); + if (k >= n / 2) + { + int profit = 0; + for (int i = 1; i < n; i++) + if (prices[i] > prices[i - 1]) + profit += prices[i] - prices[i - 1]; + return profit; + } + + vector buy(k + 1, INT_MIN); + vector sell(k + 1, 0); + + int ans = 0; + for (int i = 0; i < n; i++) + { + for (int j = 1; j <= k; j++) + { + buy[j] = max(buy[j], sell[j - 1] - prices[i]); + sell[j] = max(sell[j], buy[j] + prices[i]); + } + } + + return sell[k]; +} diff --git a/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stocks I.cpp b/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stocks I.cpp new file mode 100644 index 0000000..1017701 --- /dev/null +++ b/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stocks I.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; + +int maxProfit(const vector &A) +{ + int minVal = INT_MAX; + int maxProfit = 0; + + for (int i = 0; i < A.size(); i++) + { + if (A[i] < minVal) + minVal = A[i]; + else + { + maxProfit = max(maxProfit, A[i] - minVal); + } + } + return maxProfit; +} diff --git a/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stocks II.cpp b/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stocks II.cpp new file mode 100644 index 0000000..f0b37ba --- /dev/null +++ b/DSA/Cpp/Dynamic_Programming/Best Time to Buy and Sell Stocks II.cpp @@ -0,0 +1,23 @@ +#include "bits/stdc++.h" +using namespace std; + +int Solution::maxProfit(const vector &A) +{ + if (A.size() == 0) + return 0; + int min = A[0]; + int sum = 0; + for (int i = 1; i < A.size(); i++) + { + if (A[i] < min) + { + min = A[i]; + } + if (A[i] > min) + { + sum = sum + A[i] - min; + min = A[i]; + } + } + return sum; +} \ No newline at end of file diff --git a/WebDev/HTML-CSS/Error Page/400.html b/WebDev/HTML-CSS/Error Page/400.html new file mode 100644 index 0000000..b2b22a3 --- /dev/null +++ b/WebDev/HTML-CSS/Error Page/400.html @@ -0,0 +1,90 @@ + + + + + + + 400 | Bad request. + + + + + +
+ + +

400

+

Bad request.

+ +

We’re sorry but something appears to be wrong with the request you made, please try again.

+ + Go back +
+ + + diff --git a/WebDev/HTML-CSS/Error Page/404.html b/WebDev/HTML-CSS/Error Page/404.html new file mode 100644 index 0000000..5cbf7b9 --- /dev/null +++ b/WebDev/HTML-CSS/Error Page/404.html @@ -0,0 +1,90 @@ + + + + + + + 404 | Page not found. + + + + + +
+ + +

404

+

Page not found.

+ +

We’re sorry but it appears that we can’t find the page you were looking for. Usually this occurs because of a page that previously existed was removed or you’ve mistyped the address.

+ + Go back +
+ + + diff --git a/WebDev/HTML-CSS/Error Page/422.html b/WebDev/HTML-CSS/Error Page/422.html new file mode 100644 index 0000000..523e2b6 --- /dev/null +++ b/WebDev/HTML-CSS/Error Page/422.html @@ -0,0 +1,90 @@ + + + + + + + 422 | The change you wanted was rejected. + + + + + +
+ + +

422

+

The change you wanted was rejected.

+ +

Maybe you tried to change something you didn't have access to.

+ + Go back +
+ + + diff --git a/WebDev/HTML-CSS/Error Page/500.html b/WebDev/HTML-CSS/Error Page/500.html new file mode 100644 index 0000000..15bdab7 --- /dev/null +++ b/WebDev/HTML-CSS/Error Page/500.html @@ -0,0 +1,90 @@ + + + + + + + 500 | Internal server error. + + + + + +
+ + +

500

+

Internal Server Error.

+ +

Something went wrong. Our technical team have been notified of the issue and we are looking into it. Please try again shortly.

+ + Go back +
+ + + diff --git a/WebDev/HTML-CSS/Error Page/Sample Images/400.JPG b/WebDev/HTML-CSS/Error Page/Sample Images/400.JPG new file mode 100644 index 0000000..6a7ff95 Binary files /dev/null and b/WebDev/HTML-CSS/Error Page/Sample Images/400.JPG differ diff --git a/WebDev/HTML-CSS/Error Page/Sample Images/404.JPG b/WebDev/HTML-CSS/Error Page/Sample Images/404.JPG new file mode 100644 index 0000000..83ed534 Binary files /dev/null and b/WebDev/HTML-CSS/Error Page/Sample Images/404.JPG differ diff --git a/WebDev/HTML-CSS/Error Page/Sample Images/422.JPG b/WebDev/HTML-CSS/Error Page/Sample Images/422.JPG new file mode 100644 index 0000000..c1c51b3 Binary files /dev/null and b/WebDev/HTML-CSS/Error Page/Sample Images/422.JPG differ diff --git a/WebDev/HTML-CSS/Error Page/Sample Images/500.JPG b/WebDev/HTML-CSS/Error Page/Sample Images/500.JPG new file mode 100644 index 0000000..f77ec4e Binary files /dev/null and b/WebDev/HTML-CSS/Error Page/Sample Images/500.JPG differ diff --git a/WebDev/HTML-CSS/Error Page/readme.md b/WebDev/HTML-CSS/Error Page/readme.md new file mode 100644 index 0000000..05dccd3 --- /dev/null +++ b/WebDev/HTML-CSS/Error Page/readme.md @@ -0,0 +1 @@ +A handful of error templates to be used as a starting point for serving up 400, 404, 422 and 500 errors in your applications.