zoukankan      html  css  js  c++  java
  • [LintCode] Connecting Graph

    Given n nodes in a graph labeled from 1 to n. There is no edges in the graph at beginning.

    You need to support the following method:

    1. connect(a, b), add an edge to connect node a and node b. 2.query(a, b)`, check if two nodes are connected

    Example

    5 // n = 5
    query(1, 2) return false
    connect(1, 2)
    query(1, 3) return false
    connect(2, 4)
    query(1, 4) return true


    
    
  • 相关阅读:
    R()函数的使用 tp2
    __call()的使用
    tp3.1.3 引入静态页面
    tp3.1.3创建应用
    .env文件的使用 thinkphp51
    concat()和push()的区别
    小程序模板template使用
    56. 从1到n整数中1出现的次数
    55. 连续子数组的最大和
    54. 数据流中的中位数
  • 原文地址:https://www.cnblogs.com/lz87/p/7500092.html
Copyright © 2011-2022 走看看