C++ || Solution using Union Find with approach and comments|| Faster than 95%
Intuition\n### Sort both the array weight wise and traverse until queries is smaller then edgeList\n Describe your first thoughts on how to solve this problem. 
# Intuition\n### **Sort both the array weight wise and traverse until queries is smaller then edgeList**\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Make a parent array and initialize it with themselves.\n2. Make a answer array and initislize it with false.\n3. Swap the first and third part of edgeList to sort it w.r.t weight.\n4. Sort edgeList.\n5. Make an array to store the weights of the queries vector and their index.\n6. Traverse in the edgeList until its weight is greater than queries weight.\n7. Make their parents same in the loop which has been traversed.\n8. Outside the loop check if they have same parents means they can be traversed so make them true.\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```\nclass Solution {\npublic:\n    int dsu(vector<int>& parent,int x)\n    {\n        //Base case\n        if(parent[x] == x)\n            return x;\n        //Else check its parent\n        else\n            return parent[x] = dsu(parent,parent[x]);\n        \n    }\n    vector<bool> distanceLimitedPathsExist(int n, vector<vector<int>>& edgeList, vector<vector<int>>& queries) \n    {\n        //A parent vector to store the parent of the elements\n        vector<int> parent(n,-1);\n\n        //Answer vector to store the answer\n        vector<bool> ans(queries.size(),false);\n\n        //Make every element its own parent\n        for(int i=0;i<n;i++)\n            parent[i]=i;\n        \n        //Swap the weight index with the first index so that we can sort it by weight\n        for(int i=0;i<edgeList.size();i++)\n            swap(edgeList[i][0],edgeList[i][2]);\n\n        //Sort by Weight\n        sort(edgeList.begin(),edgeList.end());\n\n        //Store the queries weight and its index\n        vector<pair<int,int>> arr;\n\n        for(int i=0;i<queries.size();i++)\n            arr.push_back({queries[i][2],i});\n        \n        //Sort the queries w.r.t weight\n        sort(arr.begin(),arr.end());\n\n\n        int j = 0;\n        for(int i = 0; i < arr.size(); i++)\n        {\n            //Traverse until query weight is greater than the edge weight\n            while(j < edgeList.size() && edgeList[j][0] < arr[i].first)\n            {    \n                //Take the vertices of the edgelist\n                int u = edgeList[j][1],v = edgeList[j][2];\n                //Check their parents\n                int pu = dsu(parent,u),pv = dsu(parent,v);\n                //If not equal make them equal\n                if(pu != pv)\n                    parent[pu] = pv;\n                \n                j++;\n            }\n            //Take the vertices of the query \n            int x = queries[arr[i].second][0],y = queries[arr[i].second][1];\n            //Check their parents\n            int px = dsu(parent,x),py = dsu(parent,y);\n            //If parents are equal then return true\n            if(px == py)\n                ans[arr[i].second] = true;\n            \n        }\n        return ans;\n\n    }\n};\n```\n# Please Upvote if helps!!!!!
['Array', 'Union Find', 'Graph', 'Sorting', 'C++']