➤ Problem Link : 1384A. Common Prefixes
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int n; cin>>n; int arr[n]; for(int i=0;i<n;i++) cin>>arr[i]; string s; for(char i='a';i<='z';i++) s.push_back(i); for(char i='a';i<='z';i++) s.push_back(i); cout<<s<<"\n"; for(int i=1;i<=n;i++) { if(s[arr[i-1]]>'a') s[arr[i-1]]--; else s[arr[i-1]]++; cout<<s<<"\n"; } } return 0; }
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!