Skip to content

feat(algorithms, sliding-window): permutation in string#181

Merged
BrianLusina merged 3 commits intomainfrom
feat/algorithms-sliding-window-permutation-in-string
Feb 24, 2026
Merged

feat(algorithms, sliding-window): permutation in string#181
BrianLusina merged 3 commits intomainfrom
feat/algorithms-sliding-window-permutation-in-string

Conversation

@BrianLusina
Copy link
Copy Markdown
Owner

@BrianLusina BrianLusina commented Feb 24, 2026

Describe your change:

Permutation in strings

  • 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

  • New Features

    • Added two implementations for string-permutation detection: optimised and standard sliding-window approaches.
  • Documentation

    • Added a comprehensive Permutation in String guide with examples, hints and complexity analysis.
    • Updated the directory listing to include the new problem entry.
  • Tests

    • Added a parameterised test suite validating both implementations against representative cases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5cbf51 and 4fdad19.

📒 Files selected for processing (1)
  • algorithms/sliding_window/permutation_in_string/README.md

📝 Walkthrough

Walkthrough

A new "Permutation in String" sliding-window feature was added: two implementations, a README, unit tests, and a DIRECTORY entry; plus a minor trailing-comma import edit in an unrelated test.

Changes

Cohort / File(s) Summary
Directory & Docs
DIRECTORY.md, algorithms/sliding_window/permutation_in_string/README.md
Added directory entry and comprehensive README for the Permutation in String problem (definitions, examples, constraints, two solution approaches, complexity analysis, hints).
Algorithm Implementation
algorithms/sliding_window/permutation_in_string/__init__.py
Added two public functions: check_inclusion_sliding_window(s1, s2) and check_inclusion_optimised_sliding_window(s1, s2) using 26-length frequency arrays; the optimised variant tracks matching-letter count for early exit.
Tests
algorithms/sliding_window/permutation_in_string/test_permutation_in_string.py
New parameterised tests covering both implementations with example cases (expected True/False outcomes).
Minor Formatting
algorithms/graphs/min_cost_valid_path/test_min_cost_to_make_valid_path.py
Added a trailing comma in an import statement (non-functional formatting change).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through letters, one by one,
I counted beats until the match was done,
A window widens, then draws tight,
Permutations found beneath the light,
Hooray — tests pass and docs delight! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description follows the template structure and has all checklist items completed, though multiple checkboxes are marked as completed that appear questionable based on the actual changes. Review the checklist items, particularly the ones marked as completed (e.g., 'Fix a bug or typo' and 'This PR only changes one algorithm file') to ensure accuracy. The DIRECTORY.md and test file changes suggest multiple files were modified beyond the single algorithm.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a sliding-window algorithm for the permutation-in-string problem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/algorithms-sliding-window-permutation-in-string

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
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@algorithms/sliding_window/permutation_in_string/README.md`:
- Around line 25-26: The README constraint upper bound is incorrectly written as
"104"; update the constraint string "1 <= s1.length, s2.length <= 104" to use
the intended upper bound (e.g., "1 <= s1.length, s2.length <= 10^4" or "1 <=
s1.length, s2.length <= 10000") so the limits are unambiguous; locate and
replace that exact text in the README.md for the permutation_in_string sliding
window problem.
- Around line 89-90: The second bullet's description is wrong: the character
removed is at the left end of the sliding window, not the right. Update the
README text so the first bullet remains "Add the count of characters at the
right end of s2 (s2[i]) in the current window." and change the second bullet to
"Remove the count of characters at the left end of s2 (s2[i - n1]) from the
current window."—search for occurrences of s2[i - n1], i, and n1 in the
permutation_in_string README to locate and correct the wording.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc19fc4 and c5cbf51.

⛔ Files ignored due to path filters (10)
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_1.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_10.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_2.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_3.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_4.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_5.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_6.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_7.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_8.png is excluded by !**/*.png
  • algorithms/sliding_window/permutation_in_string/images/solutions/permutation_in_string_solution_9.png is excluded by !**/*.png
📒 Files selected for processing (5)
  • DIRECTORY.md
  • algorithms/graphs/min_cost_valid_path/test_min_cost_to_make_valid_path.py
  • algorithms/sliding_window/permutation_in_string/README.md
  • algorithms/sliding_window/permutation_in_string/__init__.py
  • algorithms/sliding_window/permutation_in_string/test_permutation_in_string.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@BrianLusina BrianLusina merged commit b614b2a into main Feb 24, 2026
4 of 7 checks passed
@BrianLusina BrianLusina deleted the feat/algorithms-sliding-window-permutation-in-string branch March 2, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant