GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GeeksForGeeks/string/RotateStringByTwoPlace.cpp at master · varunswing/GeeksForGeeks

Expand file tree

/

RotateStringByTwoPlace.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
46 lines (36 loc) · 788 Bytes
/

RotateStringByTwoPlace.cpp

Copy path

File metadata and controls

46 lines (36 loc) · 788 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// { Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
/* Function to check if str1 can be formed from
* str2 after rotation by 2 places
*/
bool isRotated(string str1, string str2)
{
// Your code here
int l1=str1.length(), l2=str2.length(), f=0;
if(l1==1 && l2==1){
if(str1==str2){
f=1;
}
}
string left = str2, right=str2;
rotate(left.begin(), left.begin()+2, left.end());
rotate(right.begin(), right.end()-2, right.end());
if(left==str1 || right==str1 ||f==1) return 1;
else return 0;
}
// { Driver Code Starts.
int main() {
int t;
cin>>t;
while(t--)
{
string s;
string b;
cin>>s>>b;
cout<<isRotated(s,b)<<endl;
}
return 0;
}
// } Driver Code Ends
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.