Skip to content

Add the Leetcode Solution for problem 2185. Counting Words With a Given Prefix #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jayantpatel06
Copy link

Pull Request Template

Description

✅ Step-by-Step Logic
1.Initialize a counter to keep track of how many words start with the given prefix.
2. Iterate through each word in the list.
3. For each word:

  • Check if it is at least as long as the prefix.
  • Compare each character of the word with the corresponding character in the prefix.
  1. If all characters match up to the length of the prefix, it's a valid match.
  2. If the prefix matches, increment the counter.
  3. After checking all words, return the final count.

Complexity:

  1. Time complexity: O(n*m), where n = number of words , m = length of the prefix
  2. Space complexity: O(1)

Put check marks:

Have you made changes in README file ?

  • Added problem & solution under correct topic. ✅
  • Specified Space & Time complexity.✅
  • Specified difficulty level, tag & Note(if any).

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also note any relevant details for your test configuration.

  • Passed All test cases on LeetCode ✅

Make sure all below guidelines are followed else PR will get Reject:

  • My code follows the style guidelines of this project ✅
  • I have performed a self-review of my own code ✅
  • I have commented my code so that it is easy to understand✅
  • I have made corresponding changes to the documentation✅
  • My changes generate no new warnings✅
  • Any dependent changes have been merged and published in downstream modules✅

Copy link

welcome bot commented Jul 19, 2025

I can tell this is your first pull request! Thank you I'm so honored. 🎉🎉🎉 I'll take a look at it ASAP!

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.

1 participant