Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bug Report for longest-repeating-substring-with-replacement #4891

Open
@GeorgeTof

Description

@GeorgeTof

Bug Report forhttps://neetcode.io/problems/longest-repeating-substring-with-replacement

  • The second hint states thatIt is always optimal to replace characters with the most frequent character in the string.
  • This is intuitive, but not correct.
  • Consider the following example:
    • the input stirng:ABACADAEEAEEAFAGAH and k = 1
    • If the tip were to be followed, the only character worth replacing with would beA, the one with the highest frequency, resulting in the maximum possible length equal to 3
    • Instead, the character worth replacing is the A in the middle of the group of Es with another E. Doing this will result in the length 5 and the correct answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp