当前位置: 首页 > news >正文

宣传网站建设的意义seo主要做哪些工作

宣传网站建设的意义,seo主要做哪些工作,web网站开发需求文档模板,房产网站建设本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章…

本文属于「征服LeetCode」系列文章之一,这一系列正式开始于2021/08/12。由于LeetCode上部分题目有锁,本系列将至少持续到刷完所有无锁题之日为止;由于LeetCode还在不断地创建新题,本系列的终止日期可能是永远。在这一系列刷题文章中,我不仅会讲解多种解题思路及其优化,还会用多种编程语言实现题解,涉及到通用解法时更将归纳总结出相应的算法模板。

为了方便在PC上运行调试、分享代码文件,我还建立了相关的仓库:https://github.com/memcpy0/LeetCode-Conquest。在这一仓库中,你不仅可以看到LeetCode原题链接、题解代码、题解文章链接、同类题目归纳、通用解法总结等,还可以看到原题出现频率和相关企业等重要信息。如果有其他优选题解,还可以一同分享给他人。

由于本系列文章的内容随时可能发生更新变动,欢迎关注和收藏征服LeetCode系列文章目录一文以作备忘。

There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array of nodes that node u is adjacent to. More formally, for each v in graph[u], there is an undirected edge between node u and node v. The graph has the following properties:

  • There are no self-edges (graph[u] does not contain u).
  • There are no parallel edges (graph[u] does not contain duplicate values).
  • If v is in graph[u], then u is in graph[v] (the graph is undirected).
  • The graph may not be connected, meaning there may be two nodes u and v such that there is no path between them.

A graph is bipartite if the nodes can be partitioned into two independent sets A and B such that every edge in the graph connects a node in set A and a node in set B.

Return true if and only if it is bipartite.

Example 1:

Input: graph = [[1,2,3],[0,2],[0,1,3],[0,2]]
Output: false
Explanation: There is no way to partition the nodes into two independent sets such that every edge connects a node in one and a node in the other.

Example 2:

Input: graph = [[1,3],[0,2],[1,3],[0,2]]
Output: true
Explanation: We can partition the nodes into two sets: {0, 2} and {1, 3}.

Constraints:

  • graph.length == n
  • 1 <= n <= 100
  • 0 <= graph[u].length < n
  • 0 <= graph[u][i] <= n - 1
  • graph[u] does not contain u.
  • All the values of graph[u] are unique.
  • If graph[u] contains v, then graph[v] contains u.

题意:存在一个 无向图 ,图中有 n 个节点。其中每个节点都有一个介于 0 到 n - 1 之间的唯一编号。给你一个二维数组 graph ,其中 graph[u] 是一个节点数组,由节点 u 的邻接节点组成。形式上,对于 graph[u] 中的每个 v ,都存在一条位于节点 u 和节点 v 之间的无向边。该无向图同时具有以下属性:

  • 不存在自环(graph[u] 不包含 u)。
  • 不存在平行边(graph[u] 不包含重复值)。
  • 如果 v 在 graph[u] 内,那么 u 也应该在 graph[v] 内(该图是无向图)
  • 这个图可能不是连通图,也就是说两个节点 u 和 v 之间可能不存在一条连通彼此的路径。

二分图 定义:如果能将一个图的节点集合分割成两个独立的子集 A 和 B ,并使图中的每一条边的两个节点一个来自 A 集合,一个来自 B 集合,就将这个图称为 二分图 。

如果图是二分图,返回 true ;否则,返回 false 。


解法 DFS染色判断二分图

二分图的节点可以分成两个集合,集合内的点之间没有边,任意一条边的两个节点属于不同集合,可以为图中各个节点着色,两个集合的节点分别涂成两种颜色。如果图中任何一条边的两个节点都可以被涂成不同的颜色,则该图就为二分图

一个图可能包含多个子图,需要逐次对每个子图涂色。需要一个数组 colors 标记所有节点的颜色,规定 0 0 0 表示当前未涂色, 1 1 1 表示第一种颜色, 2 2 2 表示第二种颜色。为了给所有的节点着色,需要遍历图内的所有结点,在着色的过程中若碰到「已着色、但不符合一条边两个节点不同颜色」的情况,即可判断该图不可能是二分图。

遍历图的所有结点可以使用两种方式,即广度优先搜索和深度优先搜索。这里用DFS,比较简洁:

class Solution {
public:bool isBipartite(vector<vector<int>>& graph) {int n = graph.size();vector<int> color(n);function<bool(int, int)> dfs = [&](int i, int c) {color[i] = c; // 1,2表示访问过,0表示未访问for (int j : graph[i]) {if (!color[j] && dfs(j, 3 - c) == false) return false;else if (color[j] == color[i]) {  return false; }}return true;};for (int i = 0; i < n; ++i)if (!color[i] && dfs(i, 1) == false) return false;return true;}
};
http://www.dinnco.com/news/21556.html

相关文章:

  • magento网站搬家太原百度推广开户
  • .net做网站企业文化设计
  • wordpress 会员 按月seo关键词是什么
  • 购物网站建设情况汇报免费开网店免费供货
  • 郑州网站关键词排名技术代理网络推广怎么做方案
  • 虎丘网站建设百度医生
  • 有关网站建设的外文文献seo3的空间构型
  • python网站开发 django百度一下就一个
  • 武汉网站制作开发站长之家seo
  • 用什么手机软件做网站什么是网络营销策划
  • 基于wordpress学校网站seo短视频保密路线
  • 建设网站那个好关键词举例
  • 淘宝上做微请帖的在哪个网站口碑营销的作用
  • wordpress 3.9seo优化一般包括哪些
  • 郑州做网站那网站seo优化心得
  • 成都旅游网站建设简述seo的概念
  • 建设网站的原则发布悬赏任务的推广平台
  • html模板怎么使用优化建议
  • 网站开发过程的基本环节青岛网站设计公司哪家好
  • 企业网站建设的经验心得创意营销新点子
  • python 网站建设网站运营需要多少钱
  • 湛江网站开发河北百度推广客服电话
  • 做技术类网站赚钱吗关键词seo深圳
  • 国家高新技术企业管理办法百度seo优化服务项目
  • 重庆做网站最好的商丘seo外包
  • 用word做网站相关论文seo搜索引擎优化内容
  • 做企业网站排名最全资源搜索引擎
  • 表情包做旧网站微信营销方法
  • 查法人信息的系统商丘seo推广
  • 南京网站网站建设学校百分百营销软件