Skip to content

Solution #3306 - Mridul/Edited - 11/03/2025 - #27

Open
mrid88 wants to merge 2 commits into
Dijkstra-Edu:masterfrom
mrid88:feature/count-of-substrings-vowels
Open

Solution #3306 - Mridul/Edited - 11/03/2025#27
mrid88 wants to merge 2 commits into
Dijkstra-Edu:masterfrom
mrid88:feature/count-of-substrings-vowels

Conversation

@mrid88

@mrid88 mrid88 commented Mar 11, 2025

Copy link
Copy Markdown
Member

added solution.java and explanation.md, please check.

@JRS296
JRS296 self-requested a review March 17, 2025 12:43
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 JRS296 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly make changes to the explanation.md file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants