-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
76题提错 #72
Comments
@jaydu666 您好,你标记的这里判断条件是 == 是没有问题的。理由如下: 当条件进入到 else 里面的时候,说明右窗口已经无法往右移动了,这个时候 count == len(t),窗口中已经完全包含了 t 字符串。这时窗口中左边界的字母有 2 种情况:
如果是情况 1,那么直接移动左边界,缩小窗口即可。如果是情况 2,那么左边界的 freq 一定和 t 中这个字母的 freq 相等,因为此时 count == len(t),那么这个时候要移动左边界,要把 count--。所以这里判断 freq 是否相等是正确的。 你要是把代码改成 <= 提交,代码也是可以通过的,因为 <= 是 == 的 必要不充分条件。所以这里直接写成 == 更准确一些。 |
这样,是我理解错了,非常感谢
…------------------ 原始邮件 ------------------
发件人: "halfrost"<notifications@github.com>;
发送时间: 2020年9月29日(星期二) 下午2:51
收件人: "halfrost/LeetCode-Go"<LeetCode-Go@noreply.github.com>;
抄送: "D.Jie"<871297221@qq.com>; "Mention"<mention@noreply.github.com>;
主题: Re: [halfrost/LeetCode-Go] 76题提错 (#72)
@jaydu666 您好,你标记的这里判断条件是 == 是没有问题的。理由如下:
当条件进入到 else 里面的时候,说明右窗口已经无法往右移动了,这个时候 count == len(t),窗口中已经完全包含了 t 字符串。这时窗口中左边界的字母有 2 种情况:
左边界的字母是 t 中的字母。
左边界的字母不是 t 中的字母。
如果是情况 1,那么直接移动左边界,缩小窗口即可。如果是情况 2,那么左边界的 freq 一定和 t 中这个字母的 freq 相等,因为此时 count == len(t),那么这个时候要移动左边界,要把 count--。所以这里判断 freq 是否相等是正确的。
你要是把代码改成 <= 提交,代码也是可以通过的,因为 <= 是 == 的 必要不充分条件。所以这里直接写成 == 更准确一些。
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
你写 <= 这题也能过,不过不准确。 没事,有问题随时提出来一起交流哈~💪🏻 |
好的,非常感谢,有问题再请教你
…------------------ 原始邮件 ------------------
发件人: "halfrost/LeetCode-Go" <notifications@github.com>;
发送时间: 2020年9月29日(星期二) 下午3:17
收件人: "halfrost/LeetCode-Go"<LeetCode-Go@noreply.github.com>;
抄送: "D.Jie"<871297221@qq.com>;"Mention"<mention@noreply.github.com>;
主题: Re: [halfrost/LeetCode-Go] 76题提错 (#72)
你写 <= 这题也能过,不过不准确。
没事,有问题随时提出来一起交流哈~💪🏻
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
LeetCode-Go/leetcode/0076.Minimum-Window-Substring/76. Minimum Window Substring.go
Line 27 in c1f4212
这里判断count--条件感觉有误,应该是
if sFreq[s[left]-'a'] <= tFreq[s[left]-'a'] {
The text was updated successfully, but these errors were encountered: