Skip to content

feat(algorithms, two-pointers): backspace string compare#201

Merged
BrianLusina merged 2 commits into
mainfrom
feat/backspace-string-compare
Jun 23, 2026
Merged

feat(algorithms, two-pointers): backspace string compare#201
BrianLusina merged 2 commits into
mainfrom
feat/backspace-string-compare

Conversation

@BrianLusina

@BrianLusina BrianLusina commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Describe your change:

Algorithms to check if two strings are equal after backspace characters
are applied to them.

  • 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

    • Three solution approaches added for the Backspace String Compare algorithm, utilising two-pointer and string-building strategies.
  • Documentation

    • Problem README added with problem definition, worked examples, constraints and complexity analysis for both solution methods.
  • Tests

    • Parametrised unit tests added covering multiple backspace patterns to validate all three implementations.

BrianLusina and others added 2 commits June 23, 2026 09:05
Algorithms to check if two strings are equal after backspace characters
are applied to them.
@BrianLusina BrianLusina self-assigned this Jun 23, 2026
@BrianLusina BrianLusina added Algorithm Algorithm Problem Strings Stack Stack data structure Two Pointers Two pointer algorithm Simulation labels Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c57b7baa-b1bb-4db1-92c1-5c8b2fb60b5a

📥 Commits

Reviewing files that changed from the base of the PR and between 70bb453 and 10567e6.

⛔ Files ignored due to path filters (4)
  • algorithms/two_pointers/backspace_string_compare/images/examples/backspace_string_compare_example_1.png is excluded by !**/*.png
  • algorithms/two_pointers/backspace_string_compare/images/examples/backspace_string_compare_example_2.png is excluded by !**/*.png
  • algorithms/two_pointers/backspace_string_compare/images/examples/backspace_string_compare_example_3.png is excluded by !**/*.png
  • algorithms/two_pointers/backspace_string_compare/images/examples/backspace_string_compare_example_4.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • DIRECTORY.md
  • algorithms/two_pointers/backspace_string_compare/README.md
  • algorithms/two_pointers/backspace_string_compare/__init__.py
  • algorithms/two_pointers/backspace_string_compare/test_backspace_string_compare.py

📝 Walkthrough

Walkthrough

Adds a new backspace_string_compare module under algorithms/two_pointers with three implementations (backspace_compare_two_pointers, backspace_compare_two_pointers_2, backspace_compare_build_string), a parameterised unit test suite, a problem README, and a DIRECTORY.md entry.

Changes

Backspace String Compare

Layer / File(s) Summary
Three solution functions
algorithms/two_pointers/backspace_string_compare/__init__.py
Implements backspace_compare_two_pointers using a reversed generator with zip_longest, backspace_compare_two_pointers_2 using end-to-start index traversal with per-string skip counters, and backspace_compare_build_string using a list-as-stack simulation.
Parameterised unit tests
algorithms/two_pointers/backspace_string_compare/test_backspace_string_compare.py
Defines shared (s, t, expected) test cases covering various backspace patterns and runs them against all three implementations via parameterized.expand.
README and directory index
algorithms/two_pointers/backspace_string_compare/README.md, DIRECTORY.md
Adds the full problem README with statement, examples, constraints, and complexity analysis for both approaches, plus the DIRECTORY.md link entry under Two Pointers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

enhancement, Documentation

Poem

🐇 Tap tap tap, a # appears,
Erasing letters, calming fears.
Two pointers hop from right to left,
No character wasted, none bereft.
The strings compare — both match, hooray!
This rabbit coded well today. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main addition: a new backspace string comparison algorithm using the two-pointers technique.
Description check ✅ Passed The pull request description is complete and comprehensive, covering the change description and addressing all checklist items with appropriate selections and confirmations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/backspace-string-compare

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.

@BrianLusina BrianLusina merged commit bf48799 into main Jun 23, 2026
5 of 6 checks passed
@BrianLusina BrianLusina deleted the feat/backspace-string-compare branch June 23, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Algorithm Algorithm Problem Simulation Stack Stack data structure Strings Two Pointers Two pointer algorithm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant