zoukankan      html  css  js  c++  java
  • 6.14 BFS

    1. Making A Large Island
      Input: A 2D Integer grid
      Output: the largest island when you change one 0 to 1
      Limit: can only change one 0 to 1

    如何确定largest island?

    暴力搜:每一个点都改一次

    优化的方向: 找到较大的两个Component 之间的链接通路
    被1包围的0 ? 求最值类的问题模板?

    跳过

    1. Open the Lock
      起点0000, 终点target, 中间的路径有死路
      Limit: deadends + 一次变换一个数字

    问题:每变一个数字就查一次deadends?
    可以变的数组与实际变的数字, 最短路径问题

    九章参考答案梳理:
    Hashset 存所有的deadends 字符串,同时check当前start是否是deadend
    声明一个queue结构和另一个新的hashset结构,向队列和hashset当中分别添加start
    单独声明set是为了防止重复,优化代码的效率?
    两个while循环,一个while是对所有的queue,内部的while是对于当前层的字符做遍历,

    1. Network Delay Time
      模板题目
      times[i] = (u, v, w), u是起点,v是终点,w是发送的时间
      single source all destinations shortest path
      Dijkstra's algorithm
      Bellman-Ford
      Floyd-Warshall

    对于Comparator的理解
    PriorityQueue需要声明类型 PriorityQueue(N, new Comparator() {...})

    1. Is Graph Bipartite
      Bipartite graphs
      A bipartite graph consists of sets of vertices X and Y

    2. Pacific Atlantic Water Flow

  • 相关阅读:
    2019-1-7 水晶报表
    2018-12-25工作记录 空白行===水晶报表
    2018-7-26-随笔-泛型
    2018-7-20-随笔-转换
    2018-7-18-随笔-接口
    2018-7-17-随笔-params和ref、out用法、事件访问器
    VPS安装metasploit-framework
    Mimiktaz抓取本机密码
    msfvenom生成各类Payload命令
    docker容器开启ssh远程登录
  • 原文地址:https://www.cnblogs.com/kong-xy/p/9189077.html
Copyright © 2011-2022 走看看