Solution #3306 - Mridul/Edited - 11/03/2025#27
Open
mrid88 wants to merge 2 commits intoDijkstra-Edu:masterfrom
Open
Solution #3306 - Mridul/Edited - 11/03/2025#27mrid88 wants to merge 2 commits intoDijkstra-Edu:masterfrom
mrid88 wants to merge 2 commits intoDijkstra-Edu:masterfrom
Conversation
JRS296
reviewed
Mar 17, 2025
Comment on lines
+1
to
+33
| Initialization: | ||
|
|
||
| n: Length of the word. | ||
|
|
||
| freq: Array to store the frequency of each character. | ||
|
|
||
| currConsonant: Counter for the current number of consonants in the substring. | ||
|
|
||
| cnt: Counter for the valid substrings. | ||
|
|
||
| left: Left pointer for the sliding window. | ||
|
|
||
| Iterating through the word: | ||
|
|
||
| For each character ch in the word: | ||
|
|
||
| If ch is a consonant, increment currConsonant. | ||
|
|
||
| Increment the frequency of ch in freq. | ||
|
|
||
| Checking the conditions: | ||
|
|
||
| While the current substring contains at least k consonants and all vowels: | ||
|
|
||
| Increment cnt by the number of valid substrings ending at the current position. | ||
|
|
||
| Move the left pointer to reduce the window size. | ||
|
|
||
| Decrement the frequency of the character at the left pointer. | ||
|
|
||
| If the character is a consonant, decrement currConsonant. | ||
|
|
||
| This logic ensures that we count all substrings that meet the conditions specified in the problem. No newline at end of file |
Member
There was a problem hiding this comment.
Can you utilize the markdown like your other PR's? Also add time and space complexity + how this could be further optimized (if possible)
JRS296
requested changes
Mar 17, 2025
Member
JRS296
left a comment
There was a problem hiding this comment.
Kindly make changes to the explanation.md file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
added solution.java and explanation.md, please check.