Short Palindrome Discussions | Algorithms | HackerRank

Short Palindrome

  • + 2 comments

    I recently brushed up my knowledge about graph theory (last time was like 5 years ago during my college years). However, I might be confused about one or two things. In the first test case given as an example:

    2  
    4 2    
    1 2   
    1 3  
    

    To me it seems like we can have the topology below:

    3 - 1 - 2 - 4  
    

    But it's indicated that the distance from vertex 1(S) to vertex 4 (D) is infinity.
    I cannot get my head around that, why is it supposed to be infinity while to me it is sound that is 2 edges leading then to a distance of 12? I assume that I have a pretty big misconception, in what infinity is shorter distance than say, 12?