Skip to content

Fix palindrome substring end index, correct length variable, and improve majority-element test#1

Merged
Etherstrings merged 1 commit into
masterfrom
codex/fix-spelling-error-and-code-issues
Feb 3, 2026
Merged

Fix palindrome substring end index, correct length variable, and improve majority-element test#1
Etherstrings merged 1 commit into
masterfrom
codex/fix-spelling-error-and-code-issues

Conversation

@Etherstrings

Copy link
Copy Markdown
Owner

Motivation

  • Correct incorrect substring end handling in the longest-palindrome implementation so returned results match expected inclusive end indexing.
  • Fix a spelling/variable-name issue in the squared-length helper to improve clarity.
  • Reduce space usage of the majority-element routine to O(1) and add runtime assertions to strengthen the test coverage.

Description

  • Updated L5_LongestHuiwen.longestPalindrome to use maxLength (renamed from maxlenght) and return s.substring(left, right + 1) so the end index is inclusive.
  • Fixed a typo in L593.length by renaming lenght to length and returning the computed length.
  • Replaced a HashMap-based majority counting in Test1.getShowMoreN with the Boyer–Moore majority vote algorithm and added occurrence verification; added assertion-based test cases in Test1.main to validate behavior for several inputs.

Testing

  • No automated test suite was run in this patch; only assertion-based checks were added to src/Test/Test1.java for local verification at runtime.

Codex Task

@Etherstrings Etherstrings merged commit 1cfb758 into master Feb 3, 2026
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