From 477944e3fd266d3a87bec254174ab73cd091f54e Mon Sep 17 00:00:00 2001 From: Ankur-Dwivedi22 Date: Sun, 31 Mar 2024 00:54:00 +0530 Subject: [PATCH] chore: completed day4 easy --- Easy/Day4/Solution.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Easy/Day4/Solution.cpp b/Easy/Day4/Solution.cpp index e69de29..3633c3c 100644 --- a/Easy/Day4/Solution.cpp +++ b/Easy/Day4/Solution.cpp @@ -0,0 +1,45 @@ +#include +#define ll long long +using namespace std; + +const int maxx=30; +int f[maxx]; +string s; +int n,len; + +inline void init() +{ + for(int i=0;i<=26;i++) f[i]=i; +} +inline int getf(int u) +{ + return u==f[u]?u:f[u]=getf(f[u]); +} +inline void merge(int u,int v) +{ + int t1=getf(u); + int t2=getf(v); + if(t1!=t2) f[t1]=t2; +} +int main() +{ + scanf("%d",&n); + init(); + set se; + for(int i=1;i<=n;i++) + { + cin>>s; + len=s.length(); + for(int j=1;j mp; + int ans=0; + for(set ::iterator it=se.begin();it!=se.end();it++) + { + int zz=getf(*it); + if(!mp[zz]) mp[zz]=1,ans++; + } + cout<