let 前往下载 = " http://icourse8.com/Docker_Kubernetes_k8s.html ";
章节信息
第1章 初识微服务
第2章 微服务带来的问题及解决方案分析
第3章 微服务开发
第4章 服务编排前奏
第5章 服务编排-Mesos
第6章 服务编排-DockerSwarm
第7章 服务编排-Kubernetes
第8章 CICD和DevOps
第9章 课程总结
class Solution {public: //拓扑排序,判断有无环,三步走
bool canFinish(int num, vector<pair<int, int>>& pre) {
vector<int> indegree(num,0); for(int i=0;i<pre.size();i++){ auto now = pre[i];
indegree[now.first]++; //step1
}
queue<int> q; for(int i=0;i<num;i++){ if(indegree[i]==0){ //step2
q.push(i);
}
} int cnt = 0; while(!q.empty()){ int front = q.front();
q.pop();
cnt++; for(int i=0;i<pre.size();i++){ auto now = pre[i]; if(now.second==front){
indegree[now.first]--; if(indegree[now.first]==0){ //step3
q.push(now.first);
}
}
}
} return cnt==num;
}
};
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31551894/viewspace-2647586/ ,如需转载,请注明出处,否则将追究法律责任。