# Codechef Practice | Week 5

## 1. Lapindromes: LAPIN

``````#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
string first, second;
int n = s.length();
for(int i=0;i<n/2;i++)
{
first+=s[i];
second+=s[n-i-1];
}
sort(first.begin(), first.end());
sort(second.begin(), second.end());

if(first == second)
{
cout<<"YES\n";
}
else
{
cout<<"NO\n";
}
}
}
``````

## 2. Mathison and pangrams: MATPAN

``````#include <iostream>
#include <vector>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--) {
char x = 'a';
vector<char> alpha;
vector<int> cost(26);
for (int i = 1; i <= 25; i++) {
alpha.push_back(x);
x = x + 1;
}
alpha.push_back(x);
//-----------------------------------
for (int i = 0; i < 26; i++)
cin >> cost[i];
string s;
cin >> s;
for (int i = 0; i < s.length(); i++) {
for (int j = 0; j < 26; j++)
if (s[i] == alpha[j] && alpha[j] != '0')
alpha[j] = '0';
}
int sum = 0;
for (int i = 0; i < 26; i++) {
if (alpha[i] != '0')
sum += cost[i];
}
cout << sum << endl;
}

return 0;
}
``````

## 3. Chef and Subarray: CHEFZOT

``````#include <bits/stdc++.h>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n; cin>>n;
int count = 0, m=0;
vector<int> v;
while(n--){
int x;
cin>>x;
if(x==0){
count = 0;
}
else {
count++;
m = max(m, count);
}
}
cout<<m<<endl;
return 0;
}

``````

## 4. Playing with Strings: PLAYSTR

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{   int n;
cin>>n;
int z=0,x=0;
string s;
string st;
cin>>s>>st;
for(int i=0;i<n;i++)
{
if(s[i]=='1')
z++;
if(st[i]=='1')
x++;
}

if(z==x)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;

}
return 0;
}

``````

## 5. Testing Robot: TSTROBOT

``````#include<bits/stdc++.h>
#include<iostream>
using namespace std;

int main() {
int t;
cin>>t;
while (t--){
int  n,x;
cin>>n>>x;
string s;
cin>>s;
set<int>s1;
s1.insert(x);
for(int i=0;i<n;i++){
if(s[i]=='R'){
x+=1;
s1.insert(x);
}
else{
x-=1;
s1.insert(x);
}
}
cout<<s1.size()<<endl;
}
return 0;
}
``````

KUIZZER Helping Educational website for Youngers

Welcome To Kuizzer!

KUIZZER - Helping Educational Website for YoungersYour Post is going to visible like this

Here, Your Promotional Details are going to visible for others whenever they visit the site !