You are given an integer n, an integer array nums of length n, an integer maxDiff, and a queries.
An undirected graph with n nodes labeled from n - 1 is constructed such that an edge exists between node i and node j if and only if nums[i] nums[j] maxDiff.
For each query queries[i] [u_i, v_i], determine the minimum distance (the minimum number of edges on a path) between node u_i and node v_i. If there is no path between the two nodes, the answer for that query is
Return an array of integers representing the answers to all queries.
Constraints:
n nums.length
nums[i]
maxDiff
queries.length
queries[i] [u_i, v_i]
u_i, v_i
You are given an integer n, an integer array nums of length n, an integer maxDiff, and a queries.
An undirected graph with n nodes labeled from n - 1 is constructed such that an edge exists between node i and node j if and only if nums[i] nums[j] maxDiff.
For each query queries[i] [u_i, v_i], determine the minimum distance (the minimum number of edges on a path) between node u_i and node v_i. If there is no path between the two nodes, the answer for that query is
Return an array of integers representing the answers to all queries.
Constraints:
n nums.length
nums[i]
maxDiff
queries.length
queries[i] [u_i, v_i]
u_i, v_i