diff --git a/1084-find-k-length-substrings-with-no-repeated-characters/README.md b/1084-find-k-length-substrings-with-no-repeated-characters/README.md deleted file mode 100644 index db71295..0000000 --- a/1084-find-k-length-substrings-with-no-repeated-characters/README.md +++ /dev/null @@ -1,32 +0,0 @@ - -# [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters) ![](https://img.shields.io/badge/Medium-orange) - -

Given a string s and an integer k, return the number of substrings in s of length k with no repeated characters.

- -

 

-

Example 1:

- -
-Input: s = "havefunonleetcode", k = 5
-Output: 6
-Explanation: There are 6 substrings they are: 'havef','avefu','vefun','efuno','etcod','tcode'.
-
- -

Example 2:

- -
-Input: s = "home", k = 5
-Output: 0
-Explanation: Notice k can be larger than the length of s. In this case, it is not possible to find any substring.
-
- -

 

-

Constraints:

- - - - \ No newline at end of file diff --git a/README.md b/README.md index 31be0e7..c44ec94 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A comprehensive collection of coding challenges from multiple platforms for lear | Platform | Focus Area | Problems Solved | | ------------------------------- | ---------------------------- | --------------- | -| [LeetCode](#leetcode) | Data Structures & Algorithms | 172 | +| [LeetCode](#leetcode) | Data Structures & Algorithms | 173 | | [GreatFrontEnd](#greatfrontend) | Frontend Engineering | 15 | ## Platforms @@ -226,6 +226,7 @@ Various places where I enjoy practicing solving coding challenges: - [0616 - Add Bold Tag in String](./leetcode/medium/0616-add-bold-tag-in-string) ![Medium](https://img.shields.io/badge/Medium-orange) - [0692 - Top K Frequent Words](./leetcode/medium/0692-top-k-frequent-words) ![Medium](https://img.shields.io/badge/Medium-orange) - [0760 - Bold Words in String](./leetcode/medium/0760-bold-words-in-string) ![Medium](https://img.shields.io/badge/Medium-orange) +- [1084 - Find K-Length Substrings With No Repeated Characters](./leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters) ![Medium](https://img.shields.io/badge/Medium-orange) - [2487 - Optimal Partition of String](./leetcode/medium/2487-optimal-partition-of-string) ![Medium](https://img.shields.io/badge/Medium-orange) ### Binary & Bit Manipulation @@ -333,6 +334,7 @@ Various places where I enjoy practicing solving coding challenges: - [0159 - Longest Substring with At Most Two Distinct Characters](./leetcode/medium/0159-longest-substring-with-at-most-two-distinct-characters) - Medium - [0209 - Minimum Size Subarray Sum](./leetcode/medium/0209-minimum-size-subarray-sum) - Medium - [0340 - Longest Substring with At Most K Distinct Characters](./leetcode/medium/0340-longest-substring-with-at-most-k-distinct-characters) - Medium +- [1084 - Find K-Length Substrings With No Repeated Characters](./leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters) - Medium - [More in docs →](./docs/techniques/SLIDING_WINDOW.md) ### Hash Table / Hash Map diff --git a/leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters/README.md b/leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters/README.md new file mode 100644 index 0000000..0de6f17 --- /dev/null +++ b/leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters/README.md @@ -0,0 +1,26 @@ +# [Find K-Length Substrings With No Repeated Characters](https://leetcode.com/problems/find-k-length-substrings-with-no-repeated-characters) ![Shield](https://img.shields.io/badge/Medium-orange) + +Given a string `s` and an integer `k`, +return _the number of substrings in_ `s` _of length_ `k` _with no repeated characters_. + +**Example 1:** + +```bash +Input: s = "havefunonleetcode", k = 5 +Output: 6 +Explanation: There are 6 substrings they are: 'havef','avefu','vefun','efuno','etcod','tcode'. +``` + +**Example 2:** + +```bash +Input: s = "home", k = 5 +Output: 0 +Explanation: Notice k can be larger than the length of s. In this case, it is not possible to find any substring. +``` + +**Constraints:** + +- `1 <= s.length <= 10^4` +- `s` consists of lowercase English letters. +- `1 <= k <= 10^4` diff --git a/1084-find-k-length-substrings-with-no-repeated-characters/find-k-length-substrings-with-no-repeated-characters.ts b/leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters/find-k-length-substrings-with-no-repeated-characters.ts similarity index 79% rename from 1084-find-k-length-substrings-with-no-repeated-characters/find-k-length-substrings-with-no-repeated-characters.ts rename to leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters/find-k-length-substrings-with-no-repeated-characters.ts index 73af95b..f2340a6 100644 --- a/1084-find-k-length-substrings-with-no-repeated-characters/find-k-length-substrings-with-no-repeated-characters.ts +++ b/leetcode/medium/1084-find-k-length-substrings-with-no-repeated-characters/find-k-length-substrings-with-no-repeated-characters.ts @@ -1,8 +1,8 @@ /** - * @time - O(n) where n is the length of s - * @space - O(n) where n is the length of s + * @time - O(n) where n is the length of s + * @space - O(n) where n is the length of s */ -function numKLenSubstrNoRepeats(s: string, k: number): number { +export function numKLenSubstrNoRepeats(s: string, k: number): number { const n = s.length; if (k > n) { @@ -40,5 +40,5 @@ function numKLenSubstrNoRepeats(s: string, k: number): number { } } - return count; -}; \ No newline at end of file + return count; +}