We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
lucifer1004的CP笔记
https://cp-wiki.vercel.app/tutorial/leetcode/WC231/
The text was updated successfully, but these errors were encountered:
想请教下大佬,21-28行的时间复杂度怎么计算的呀?看上去套了三重循环,不太会分析呀
Sorry, something went wrong.
@codelh7 注意所有的groups[i]最多有N个元素,所以最内层循环的执行次数最多是N次。
groups[i]
N
这种分析就类似于图的遍历:
for (int u = 0; u < n; ++u) { for (int v : adj[u]) { // do something... } }
看上去是两层循环,实际上内层执行的总次数为O(E)次。
O(E)
No branches or pull requests
Leetcode 第231场周赛题解 | CP Wiki
lucifer1004的CP笔记
https://cp-wiki.vercel.app/tutorial/leetcode/WC231/
The text was updated successfully, but these errors were encountered: