We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Going to the Office
Going to the Office
Sort by
recency
|
25 Discussions
|
Please Login in order to post a comment
In the absence of the editorial, I'll provide a brief explanation of my solution for those who may be struggling (This could be seen as a self-note rather than a complete explanation) : Use any shortest-path algorithm to find the shortest distance from
Source
andSink
to other nodes. Construct a graph so-called shortest-path graphG
in which an edge u->v presents if and only ifd[u] + w(u,v) == d[v]
whered[x]
is the shortest distance fromSource
tox
andw(u,v)
is the weight of that edge. Consider the induced graphG'
of vertices that can reachSink
fromG
, if the deleted edge is not a bridge ofG'
, then the shortest distance fromSource
toSink
won't change. Otherwise, that bridge separatesG
into two disjoint components, the new shortest distance isd_source[u] + w(u,v) + d_sink[v]
assuming that u belongs to the source's and v belongs to the sinkscomponent. By applying sweepline algorithm + a min heap / multiset, we can precompute the answer for all such bridges in O(N + ElogN) times.Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Going to the Office Problem Solution
Here is the solution of Going to the Office Click Here
Here is problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-going-to-the-office-problem-solution.html
I want to implement this code in my office cleaning company. Can you please give me permission to use it.