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


    
    
  • 相关阅读:
    Android源码学习之模板方法模式应用
    CSS3特性修改(自定义)浏览器默认滚动条
    【JQ+锚标记实现点击页面回到顶部】
    网页响应式媒体查询
    CSS3新特性,绘制常见图形
    【CSS3动画】transform对文字及图片的旋转、缩放、倾斜和移动
    MySQL索引详解
    Eclipse快捷键大全(转载)
    深入Java集合学习系列:HashMap的实现原理
    HTML5 的Drawing Path
  • 原文地址:https://www.cnblogs.com/lz87/p/7500092.html
Copyright © 2011-2022 走看看