problem link
code link
plz tell why this code is not getting submit and correct the code as well…along with explaination…
plz reply to this doubt as soon as possible…
problem link
code link
plz tell why this code is not getting submit and correct the code as well…along with explaination…
plz reply to this doubt as soon as possible…
for(int i=0;i<v.size()-1;i++)
{
int x=v[i+1];
int y=v[i];
for(auto z:mp[y])
{
if(z.first==x)
{
w=z.second;
break;
}
}
if(cs==0)
{
sum+=w;
cs++;
}
else
{
int var=w-sum;
if(var>0)
sum+=var;
}
}
hey can u explain me the logic for this loop
shouldn’t this be simply that first u marked the shortest path to each node, and marked it’s parent
u just have to subtract the distance of the parent from the distance of this
if it is less than zero mark it as zero else take it as it is
yeah i tried doing that only through this code you plz provide me correct code for this …