Skip to content

1059. All Paths from Source Lead to Destination #77

@altay9

Description

@altay9

https://leetcode.com/problems/all-paths-from-source-lead-to-destination

leadsToDestination(int n, int[][] edges, int source, int destination)
Buradaki edges: graph'teki node'ların birbirleri ile olan bağlantılarını, source, kaynak node'un değerini, destination ise hedef node'un değerini göstermektedir.

Source değerini içeren node'dan çıkan tüm yolların, nihâyetinde her zamân destination'a varıp varmayacağı soruluyor.

Bunu belirlemek için şu şartlar kontrol edilmeli:

  • Source'tan, destination'a en az bir yol var mı?
  • Eğer Source'tan herhangi bir yol var ise ve node'un ardında gelen başka bir kenar yok ise, destination bu node'dur.
  • Source'tan, destination'a giden yollar sınırlı sayıdadır.

Varsayılan kod:

class Solution {
    public boolean leadsToDestination(int n, int[][] edges, int source, int destination) {
        
    }
}

Örnekler incelenirse çok daha rahat anlaşılacaktır:
https://leetcode.com/problems/all-paths-from-source-lead-to-destination/

image
image
image
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions