From d743284636136593cf76acdc11fd35c6f3a48e55 Mon Sep 17 00:00:00 2001 From: "Dr.Dread" <135847306+DrDread746@users.noreply.github.com> Date: Wed, 29 Oct 2025 09:48:13 +0530 Subject: [PATCH 1/3] 3297. Count Substrings That Can Be Rearranged to Contain a String I --- ...an Be Rearranged to Contain a String I.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 3297. Count Substrings That Can Be Rearranged to Contain a String I.cpp diff --git a/3297. Count Substrings That Can Be Rearranged to Contain a String I.cpp b/3297. Count Substrings That Can Be Rearranged to Contain a String I.cpp new file mode 100644 index 0000000..42bcd5e --- /dev/null +++ b/3297. Count Substrings That Can Be Rearranged to Contain a String I.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + long long validSubstringCount(string word1, string word2) { + int count = 0; + long long ans = 0; + int l = 0, r = 0; + vector map2(27, 0), map1(27, 0); + for (int i = 0; i < word2.size(); i++) { + map2[word2[i] - 'a']++; + } + while (r < word1.size()) { + map1[word1[r] - 'a']++; + if (map1[word1[r] - 'a'] == map2[word1[r] - 'a']) + count += map2[word1[r] - 'a']; + while (count == word2.size()) { + ans += (word1.size() - r); + map1[word1[l] - 'a']--; + if (map1[word1[l] - 'a'] < map2[word1[l] - 'a']) + count -= map2[word1[l] - 'a']; + l++; + } + r++; + } + return ans; + } +}; From 90556cd95125738edd9b7a9dd3ed4f2af4589f05 Mon Sep 17 00:00:00 2001 From: "Dr.Dread" <135847306+DrDread746@users.noreply.github.com> Date: Wed, 29 Oct 2025 09:57:36 +0530 Subject: [PATCH 2/3] 3298. Count Substrings That Can Be Rearranged to Contain a String II --- ...n Be Rearranged to Contain a String II.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 3298. Count Substrings That Can Be Rearranged to Contain a String II.cpp diff --git a/3298. Count Substrings That Can Be Rearranged to Contain a String II.cpp b/3298. Count Substrings That Can Be Rearranged to Contain a String II.cpp new file mode 100644 index 0000000..42bcd5e --- /dev/null +++ b/3298. Count Substrings That Can Be Rearranged to Contain a String II.cpp @@ -0,0 +1,26 @@ +class Solution { +public: + long long validSubstringCount(string word1, string word2) { + int count = 0; + long long ans = 0; + int l = 0, r = 0; + vector map2(27, 0), map1(27, 0); + for (int i = 0; i < word2.size(); i++) { + map2[word2[i] - 'a']++; + } + while (r < word1.size()) { + map1[word1[r] - 'a']++; + if (map1[word1[r] - 'a'] == map2[word1[r] - 'a']) + count += map2[word1[r] - 'a']; + while (count == word2.size()) { + ans += (word1.size() - r); + map1[word1[l] - 'a']--; + if (map1[word1[l] - 'a'] < map2[word1[l] - 'a']) + count -= map2[word1[l] - 'a']; + l++; + } + r++; + } + return ans; + } +}; From 194e7e96c79750d51ca0a65f9b3c96646e618713 Mon Sep 17 00:00:00 2001 From: "Dr.Dread" <135847306+DrDread746@users.noreply.github.com> Date: Wed, 29 Oct 2025 10:27:26 +0530 Subject: [PATCH 3/3] 3439. Reschedule Meetings for Maximum Free Time I --- ...edule Meetings for Maximum Free Time I.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 3439. Reschedule Meetings for Maximum Free Time I.cpp diff --git a/3439. Reschedule Meetings for Maximum Free Time I.cpp b/3439. Reschedule Meetings for Maximum Free Time I.cpp new file mode 100644 index 0000000..46f192a --- /dev/null +++ b/3439. Reschedule Meetings for Maximum Free Time I.cpp @@ -0,0 +1,23 @@ +class Solution { +public: + int maxFreeTime(int eventTime, int k, vector& startTime, vector& endTime) { + int n = startTime.size(); + vector temp(n + 1, 0); + temp[0] = startTime[0] - 0; + temp[n] = eventTime - endTime[n - 1]; + for (int i = 1; i < n; i++) { + temp[i] = startTime[i] - endTime[i - 1]; + } + int l = 0, r = 0, tempsum = 0, maxsum = 0; + while (r < temp.size()) { + tempsum += temp[r]; + if ((r - l) == k) { + maxsum = max(maxsum, tempsum); + tempsum -= temp[l]; + l++; + } + r++; + } + return maxsum; + } +};