Comments (4)
from leetcode-go.
@jaydu666 您好,你标记的这里判断条件是 == 是没有问题的。理由如下:
当条件进入到 else 里面的时候,说明右窗口已经无法往右移动了,这个时候 count == len(t),窗口中已经完全包含了 t 字符串。这时窗口中左边界的字母有 2 种情况:
-
- 左边界的字母是 t 中的字母。
-
- 左边界的字母不是 t 中的字母。
如果是情况 1,那么直接移动左边界,缩小窗口即可。如果是情况 2,那么左边界的 freq 一定和 t 中这个字母的 freq 相等,因为此时 count == len(t),那么这个时候要移动左边界,要把 count--。所以这里判断 freq 是否相等是正确的。
你要是把代码改成 <= 提交,代码也是可以通过的,因为 <= 是 == 的 必要不充分条件。所以这里直接写成 == 更准确一些。
from leetcode-go.
from leetcode-go.
你写 <= 这题也能过,不过不准确。
没事,有问题随时提出来一起交流哈~💪🏻
from leetcode-go.
Related Issues (20)
- 0027 Remove Element 有道题不明白 HOT 2
- A problem in 707. Design Linked List HOT 1
- Clone Error HOT 1
- 918. Maximum Sum Circular Subarray HOT 4
- 763 PartitionLabels 时间复杂度 HOT 1
- 关于此电子书如何搭建 HOT 5
- Windows系统下 关于 Clone 的问题 HOT 7
- When click the 's' key in the keyboard will trigger website search input box to be enable
- 0114.Flatten-Binary-Tree-to-Linked-List test case wrong HOT 5
- 是否可以提供epub版本 HOT 2
- Query: How book is generated? HOT 1
- Query: What is the technology behind web ? thank you HOT 5
- 怎么开启暗黑模式 HOT 3
- 0004 bug
- Can you re-arrange the layout of PDF to put the title and solution of question on the same page? HOT 1
- Hacking Facebook account HOT 4
- LeetCode第七题Reverse-Integer HOT 2
- leetcode 2038题, segment Tree的模板 HOT 1
- 1004 Max Consecutive Ones III HOT 3
- 霜神,你好,我有时候并最优解的go代码转成python之后,时空复杂度就变的很差,是不是语言的问题?目前上传的这一千多道题都基本上是go的最优解吗? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leetcode-go.