Tell me if my alternative approach is right or not


this is my code

i am not getting correct answer though i am trying to figure it out

hello @singh.pankhil40
no this is not correct.
the reason is that map m will order its data based on vertices number and not on basis of distance.

check ur course video for code and explanation of algorithm

i am not getting with the help of set

the order set has property that it arranges data in ascending order (by default) . so we are making use of this property of set.
i.e we are picking the very first entry of set (because it will be smallest) and then using that entry we are visiting all the neighbouring nodes, calculating its distance and updating accordingly and inserting in the set if ditance of new node is updated


tell me why i am getting wrong answer this is exact same code as of prateek sir

@singh.pankhil40
check ur cin statement .
it should be cin>>x>>y>>w;