Skip to content

Add docstring documentation including time and space complexity analysis and unit tests for the "Count Asterisks" problem.#89

Merged
kobukuro merged 1 commit intomainfrom
test/add-count-asterisks-tests
Feb 25, 2026
Merged

Add docstring documentation including time and space complexity analysis and unit tests for the "Count Asterisks" problem.#89
kobukuro merged 1 commit intomainfrom
test/add-count-asterisks-tests

Conversation

@kobukuro
Copy link
Owner

No description provided.

…sis and unit tests for the "Count Asterisks" problem.
Copilot AI review requested due to automatic review settings February 25, 2026 00:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 BaseTestSolution runner.
  • 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_search is 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.

@kobukuro kobukuro merged commit 3e53bf0 into main Feb 25, 2026
5 checks passed
@kobukuro kobukuro deleted the test/add-count-asterisks-tests branch February 25, 2026 00:39
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