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.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Graph Theory
  4. Going to the Office
  5. Discussions

Going to the Office

Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • pctablet505
    2 years ago+ 2 comments

    I guess it can be solved using A* search algorithm, Dijkstra

    Find Office to all nodes shortest distance and store it in a dictionary.

    Find shortest path from home to office and store all edges in a set.

    If deleted edge is not in shortest path, return stored shortest path length O(1)

    if it is in shortest paththen use A* algorithm using Office to Node shortest path as Heurestic for A* Worst case complexity of dijkstra but several times better than dijkstra...

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature