➤ Problem Link : BLKEK
👉 Hint : edit please
✅ C++ Solution :
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int dp[2000]; while(n--) { string s; int k=0,kval=0,eval=0; cin>>s; memset(dp,0,sizeof(dp)); for(int i=s.length()-1;i>=0;i--) { if(s[i]=='K') { k++; kval+=eval; } else if(s[i]=='E') { eval+=k; } } cout<<kval<<endl; } 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!!