abhisek247767 / LeetCode2024-6Companies30Days

Make your first Pull Request on Hacktoberfest 2024. Don't forget to spread love and if you like give us a ⭐️
40 stars 64 forks source link

Efficient Solution for Network Delay Time Problem Using Dijkstra's Algorithm in C++ #151

Closed poshithNandyala closed 1 month ago

poshithNandyala commented 1 month ago

This pull request addresses issue #105 and provides an efficient solution to the Network Delay Time problem, implemented in C++. The problem involves determining the minimum time required for all nodes in a directed, weighted network graph to receive a signal sent from a specified starting node, k. If any nodes are unreachable, the solution returns -1 to indicate this.

The approach uses Dijkstra's Algorithm for shortest-path computation, ensuring an optimal time complexity for large graphs by utilizing a min-heap (priority queue) to manage nodes in the order of their current shortest distance from the source node. This solution:

Summary of Changes

Additional Information

This solution provides clarity and efficiency in handling the Network Delay Time problem, offering robust performance for the upper bounds of constraints.

github-actions[bot] commented 1 month ago

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that you star the repository and follow me in github,otherwise PR will not merged. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

abhisek247767 commented 1 month ago

can you write the algo in same cpp file with explanation which you write in txt file.

poshithNandyala commented 1 month ago

I have added in-code explanations for Dijkstra's algorithm within the same CPP file. Please review the changes.