2608. Shortest Cycle in a Graph (Leetcode Hard)

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

Комментарии • 4

  • @Algorithmist
    @Algorithmist  Год назад

    Did you get all the way around?

  • @zweitekonto9654
    @zweitekonto9654 19 дней назад

    Why can this not be solved using a DFS by maintaining a step count along the way. If we find a node with a smaller step count, the length of the cycle is (step_count_child - step_count_current + 1)?

  • @nitinbhattacharyya8784
    @nitinbhattacharyya8784 Год назад

    I had a question what if this question wasn't to find the shortest cycle but the longest in an undirected graph?Doing the way by breadth first search would it not exclude a larger cycle if that cycle comprised of two or more smaller cycles?

    • @Algorithmist
      @Algorithmist  Год назад

      That's a totally different problem, and it would depend on a lot of definitions, but probably exponential