Skip to content

文章中有一处代码有缺陷 #41

Description

@sh1luo

文件地址:algorithm-pattern/introduction/quickstart.md

问题strStr,问题代码:

func strStr(haystack string, needle string) int {
    if len(needle) == 0 {
        return 0
    }
    ....
}

如果子串长度为0的话返回0有歧义,误认为子串起始地址为0,我觉得改为负数之类的更好。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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