 # NEWD-Editorial

Author: Setter’s name
Tester: Tester’s name

# DIFFICULTY:

EASY.
Intermediate levels like EASY-MEDIUM is also possible.

String

# PROBLEM:

In the given question chef wants to find if the order of the initials in his list and the order in which the employees are sitting can be matched by rotating the table or not. The table can only be rotated in a clockwise direction. Help the chef to find whether the list is correct or not.

# QUICK EXPLANATION:

We can concatenate the given string with itself and check whether the string i.e the order after rotating the table is substring of the concatenated string or not

# EXPLANATION:

Firstly we will create a temp string and store the concatenation of the first string.
Now we will check whether the string i.e the order of initials of employees after the rotation of the table is a substring of temp.
If the order of the employees after rotation of the table is the same as mentioned in the chef’s list then the string we will be the substring of the temp and the chef’s list is correct.
If it is not the substring of the temp then the chef’s list is wrong.

# SOLUTIONS:

Setter's Solution
``````#include<bits/stdc++.h>
using namespace std;

bool ifpossible(string s,string u) {

if(s.length()!=u.length())
return false;

string combine = s + s;
return (combine.find(u)!=string::npos);
}

int main() {

int t;
cin>>t;
while(t--)
{
string s,u;
cin>>s>>u;
if(ifpossible(s,u))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
``````
Tester's Solution
``````while True:
try:
for _ in range(int(input())):
s1 = input().strip()
s2 = input().strip()
if len(s1)!=len(s2):
print("NO")
elif s1==s2:
print("YES")
else:
flag=0
for i in range(len(s2)):
if (s2[i:]+s2[0:i])==s1:
flag=1
break
if flag:
print("YES")
else:
print("NO")
except:
break
``````