Conversation
…sis and unit tests for the "Count Asterisks" problem.
There was a problem hiding this comment.
Pull request overview
This PR adds a new Easy problem implementation (“Count Asterisks”, #2315) along with pytest-based unit tests, and includes inline documentation describing the approach and complexity.
Changes:
- Added
Solution.count_asterisks()implementation for counting*outside|...|pairs. - Added pytest parametrized tests wired into the shared
BaseTestSolutionrunner. - Added/maintained package structure under
problems/easy/count_asterisks_2315/.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| problems/easy/count_asterisks_2315/solution.py | Implements the solution and adds a docstring with time/space complexity discussion. |
| problems/easy/count_asterisks_2315/test_solution.py | Adds parametrized unit tests using BaseTestSolution._run_test. |
| problems/easy/count_asterisks_2315/init.py | Package marker for the problem module. |
Comments suppressed due to low confidence (2)
problems/easy/count_asterisks_2315/test_solution.py:15
- Test function name
test_searchis misleading for this problem; it should reflect the method under test (e.g.,test_count_asterisks) to match the naming pattern used in other problem test suites and improve readability in pytest output.
def test_search(self, method_name, s, expected, timeout):
self._run_test(self.solution, method_name, (s,), expected, timeout)
problems/easy/count_asterisks_2315/solution.py:16
- The time-complexity breakdown in the docstring is a bit inaccurate/unclear: the loop is over the number of split segments (<= n+1), not "half of the words" in terms of string length, so describing it as O(n/2) is misleading. Consider restating the analysis in terms of segments (k) or simply as overall O(n) due to split + single pass over characters.
Time complexity: O(n) where n is the length of string s
- split operation: O(n)
- iterating through half of the words: O(n/2)
- counting asterisks in words: O(n) total
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.