Question: MasterCard, Online Assessment | BOB and Alice | String Related Problem | 5th August 2023
1
Entering edit mode

ADD COMMENTlink 16 months ago PoGo 2.4k
0
Entering edit mode

Both questions were very easy (LEETCODE)

ADD COMMENTlink 16 months ago Systumm • 200
0
Entering edit mode

Question 1 Solution

void solve()
{
string k,s;
cin>>k>>s;
int n=k.length();
int m=s.length();
int A[n];
for(int i=0;i<n;i++)
A[i]=k[i]-'a';
//f(i,n)
//cout<<A[i]<<" ";
cout<<endl;
string ans;
int i=0;
for(int j=0;j<m;j++)
{
    int x=((s[j]-'a')+A[i%n])%26;
ans+=char('a'+x);
i++;
}
cout<<ans<<endl;
}

 

ADD COMMENTlink 16 months ago suryansh jaiswal • 370

Login before adding your answer.

Similar Posts
Loading Similar Posts