Skip to content

Conversation

@BrianLusina
Copy link
Owner

@BrianLusina BrianLusina commented Jan 27, 2026

Describe your change:

First unique character in string

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added the "First Unique Character" algorithm, which identifies the index of the first non-repeating character in a string, or -1 if none exists.
  • Documentation

    • Provided comprehensive problem documentation with descriptions, example cases, and constraints.
  • Tests

    • Added test suite to verify the algorithm's correctness across various test cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@BrianLusina BrianLusina self-assigned this Jan 27, 2026
@BrianLusina BrianLusina added enhancement Algorithm Algorithm Problem Datastructures Datastructures Documentation Documentation Updates Strings Hash Map Hash Map Data structure Counting labels Jan 27, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new algorithm for the "First Unique Character" problem in the hash table category. It includes problem documentation, a working implementation using character frequency counting, comprehensive test coverage with parameterized test cases, and updates to the directory index.

Changes

Cohort / File(s) Summary
Documentation
DIRECTORY.md, algorithms/hash_table/first_unique_character/README.md
Added directory index entry and comprehensive README documenting the problem statement, constraints, and three worked examples
Implementation
algorithms/hash_table/first_unique_character/__init__.py
New first_unique_character(s: str) -> int function using collections.Counter to identify character frequencies and return the index of the first non-repeating character, or -1 if none exist
Tests
algorithms/hash_table/first_unique_character/test_first_unique_character.py
New test module with parameterized test cases covering multiple input scenarios using unittest and parameterized decorators

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A new algorithm hops into place, finding unique characters with grace!
The Counter counts with speed so bright,
First unique found—the answer's right! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a 'first unique character in string' algorithm to the hash table category.
Description check ✅ Passed The description includes all required sections and checklist items are mostly complete; however, the 'Description' section lacks detail about what the change does, and one checklist item about issue resolution is correctly left unchecked.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@algorithms/hash_table/first_unique_character/README.md`:
- Around line 1-35: Add a reference URL for the problem statement to the README
for "First Unique Character": update the top description block (the section
starting with the title "First Unique Character" and the one-line problem
statement) to include a source link (for example LeetCode problem URL) labeled
clearly as "Reference" or "Source" immediately after the description paragraph
so readers can follow to the original problem; ensure the link is a full URL and
use the same README header area where the problem is described.

In `@DIRECTORY.md`:
- Around line 169-170: The unordered list items for "First Unique Character" are
mis-indented causing markdownlint MD007; fix by aligning the two list lines to
the same nesting level as the surrounding "Hash Table" block—ensure the bullet
for "First Unique Character" and its nested link line use consistent spaces
(match the other top-level list item indentation in the Hash Table section) so
both the item label "First Unique Character" and the link "[Test First Unique
Character](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/hash_table/first_unique_character/test_first_unique_character.py)"
share the same indentation depth and the UL nesting is consistent.

@BrianLusina BrianLusina merged commit 6d3a341 into main Jan 27, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Algorithm Algorithm Problem Counting Datastructures Datastructures Documentation Documentation Updates enhancement Hash Map Hash Map Data structure Strings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants