Skip to content

fix: use strict inequality to avoid containerOutOfBounds #2981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

vil02
Copy link
Member

@vil02 vil02 commented Aug 16, 2025

Description of Change

Observe that in the old code, because the <= is used in the loop, there is an index out of bounds error. The main reason for this PR is to fix this problem. The rest is just fix as you go:

  • std::size_t should be used for indexing standard containers,
  • the api is slightly more intuitive now (consider calling the build function twice in the old code).

Checklist

  • Added description of change
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:
Fix one-off error leading to index out of bounds.

@vil02 vil02 marked this pull request as ready for review August 16, 2025 20:31
@vil02 vil02 force-pushed the fix_containerOutOfBounds branch from 4d3eaac to 145d28d Compare August 16, 2025 22:40
@realstealthninja realstealthninja merged commit 93c64b5 into TheAlgorithms:master Aug 17, 2025
7 checks passed
@vil02 vil02 deleted the fix_containerOutOfBounds branch August 17, 2025 11:10
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