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

  • 相关阅读:
    Python笔试题(递归)
    MYSQL经典面试题
    Linux常用命令
    HTTP协议相关面试题
    Flask面试题
    史上最全DVWA 笔记
    ssh root Permission denied
    odoo Reference 选择model 然后选择record
    定体, 定压, 定温, 绝热 Q E A 公式
    Vmware Bluetooth
  • 原文地址:https://www.cnblogs.com/kong-xy/p/9189077.html
Copyright © 2011-2022 走看看