PriorityQueue
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```csharp []\npublic class Solution {\n    private int mod = 1000000007;\n    public class Pair\n\t{\n\t\tpublic int node;\n\t\tpublic int weight;\n\t\tpublic Pair(int curNode, int w)\n\t\t{\n\t\t\tnode = curNode;\n\t\t\tweight = w;\n\t\t}\n\t}\n\n\tpublic class PairComp : IComparer<Pair>\n\t{\n\t\tpublic int Compare(Pair x, Pair y)\n\t\t{\n\t\t\treturn x.weight.CompareTo(y.weight);\n\t\t}\n\t}\n\n    public int CountRestrictedPaths(int n, int[][] edges) {\n \t\t\t// Init and define adj array:\n\t\t\tHashSet<Pair>[] adj = new HashSet<Pair>[n+1];\n\t\t\tfor (int i = 0; i <= n; i++)\n\t\t\t{\n\t\t\t\tadj[i] = new HashSet<Pair>();\n\t\t\t}\n\n\t\t\tforeach (int[] edge in edges)\n\t\t\t{\n\t\t\t\tint u = edge[0], v = edge[1], w = edge[2];\n\t\t\t\tadj[u].Add(new Pair(v, w));\n\t\t\t\tadj[v].Add(new Pair(u, w));\n\t\t\t}\n\n\t\t\tint[] dist = Enumerable.Repeat(int.MaxValue, n+1).ToArray();\n\t\t\tlong[] res = new long[n+1];\n            dist[n] = 0;\n            res[n] = 1;\n\t\t\tPriorityQueue<int, int> pq = new PriorityQueue<int, int>();\n\t\t\tpq.Enqueue(n, 0);\n\n\t\t\twhile (pq.TryDequeue(out int node, out int weight))\n\t\t\t{ \n\t\t\t\tif (weight > dist[node])\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (node == 1)\n                    break;\n\t\t\t\n\t\t\t\tforeach (Pair neighbor in adj[node])\n\t\t\t\t{ \n\t\t\t\t\tint nextW = neighbor.weight, nextNode = neighbor.node;\n\t\t\t\t\tif (dist[nextNode] > (dist[node] + nextW))\n\t\t\t\t\t{\n\t\t\t\t\t\tdist[nextNode] = (dist[node] + nextW);\n\t\t\t\t\t\tpq.Enqueue(nextNode, dist[nextNode]);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (dist[nextNode] > dist[node])\n\t\t\t\t\t{\n\t\t\t\t\t\tres[nextNode] += res[node];\n\t\t\t\t\t\tres[nextNode] %= mod;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn (int)res[1];\n\n    }\n}\n```
['C#']