need help with union find approach || cpp || uninon-find
\nclass Solution {\npublic:\n    long  dist(long a,long b,long x,long y){\n        return sqrt(pow((a-x+0ll),2.0) + pow((b-y+0ll),2.0));\n    }\n    // static b
```\nclass Solution {\npublic:\n    long  dist(long a,long b,long x,long y){\n        return sqrt(pow((a-x+0ll),2.0) + pow((b-y+0ll),2.0));\n    }\n    // static bool cmp(vector<int> &a,vector<int> &b){\n    //     return a[2]>b[2];\n    // }\n    int getp_(vector<int> &p,int x){\n        if(p[x]==x)return x;\n        return p[x]=getp_(p,p[x]);\n    }\n    void union_(vector<int> &p,vector<int> &r,int x,int y){\n        int px=getp_(p,x) , py=getp_(p,y);\n        if(px==py)return;\n        \n        if(r[px]>r[py]){\n            p[py]=px;\n        }else if(r[py]>r[px]){\n            p[px]=py;\n        }else{\n            p[px]=py;\n            r[py]++;\n        }\n    }\n    int maximumDetonation(vector<vector<int>>& bmb) {\n        int n=bmb.size();\n        vector<int> p(n,0),r(n,0);\n        \n        for(int i=0;i<n;++i){\n            p[i]=i;\n        }\n        \n        \n        for(int i=0;i<n;++i){\n            for(int j=0;j<n;++j){\n                // if(i!=j){\n                    int dt=dist(bmb[i][0],bmb[i][1],bmb[j][0],bmb[j][1]);\n                    if(dt<=bmb[i][2]){\n                        union_(p,r,i,j);\n                    }\n                // }\n            }\n        }\n        \n        unordered_map<int,int> ump;\n        int ans=1;\n        for(int i=0;i<n;++i){\n            ans=max(ans,++ump[getp_(p,i)]);\n        }\n        \n        return ans;\n//         vector<vector<int>> exp(bmb.size());\n//         sort(bmb.begin(),bmb.end(),cmp);\n//         for(int i=0;i<bmb.size();++i){\n//             cout<<i<<" -> ";\n//             for(int j=i+1;j<bmb.size();++j){\n//                 int dt=dist(bmb[i][0],bmb[i][1],bmb[j][0],bmb[j][1]);\n//                 if(dt<=bmb[i][2]){\n//                     exp[i].push_back(j);\n//                     cout<<j<<" ";\n//                 }\n//             }\n//             cout<<endl;\n//         }\n        \n//         int ans=1;\n//         vector<int> blast(bmb.size(),0);\n//         for(int i=bmb.size()-1;i>=0;--i){\n//             int t=1;\n//             for(int j=0;j<exp[i].size();++j){\n//                 t+=blast[exp[i][j]];\n//             }\n//             blast[i]=t;\n//             ans=max(ans,t);\n//         }\n        \n//         return ans;\n    }\n};\n```
[]