MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

HackerEarth_problems/Rotation/solution.cpp:5–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5int main()
6{
7 int n,count=0;
8 string s,t;
9 cin>>n;
10 cin>>s;
11 cin>>t;
12 if(s.compare(t) ==0) // check if both the strings are same or not
13 cout<<0<<endl;
14 else
15 {
16 for(int i=n-1;i>=0;i--)
17
18 {
19 count++;
20 s.erase(0,1); // remove start character from string s
21 t.erase(i,1); // remove last character from string t
22 if(s.compare(t)==0) // if botth the strings are same then break
23 break;
24 }
25 cout<<count<<endl; // print the minimum number to convert s to t.
26 }
27
28
29}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected