Minimum Penalty Path Discussions | Algorithms | HackerRank
  • Asked to answer
    + 4 comments
    Endorsed by f2014044

    Consider this

    A ->B -> C Cost (A,B)->1 (B,C) ->2 and (A,B) ->2 (Multiple edges can exist)

    In this case your approach from A to C will give 3. But the answer is 2.

    • + 1 comment

      Thanks! I undestood the error.

      • + 1 comment

        I am using same approach, but i have answer is 2, for case A ->B -> C Cost (A,B)->1 (B,C) ->2 and (A,B) ->2, but tests cases 5,8, 10 - 13, is wrong answer. Where is error?

        • + 1 comment

          Same for me. Did you find the reason?

          • + 2 comments

            No, I can't find it.

            • + 0 comments

              fionalmatters explained why Djikstra won't work:

              https://www.hackerrank.com/challenges/beautiful-path/forum/comments/137106

    • + 0 comments

      Nice!!

    • + 1 comment

      so, there's no way to do it with djikstra?

      • + 0 comments

        I think yes

    • + 0 comments

      Thanks!!!!!!