Skip to content

Commit 796e643

Browse files
committed
Added 731A - Night at the Museum.cpp
1 parent 74d5d1b commit 796e643

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

731A - Night at the Museum.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
int main()
7+
{
8+
string s;
9+
cin>>s;
10+
char prev='a';
11+
int r=0;
12+
for(int i=0;i<s.size();i++)
13+
{
14+
char curr=s[i];
15+
int right=abs(curr-prev);
16+
int left=abs(abs(curr-prev)-26);
17+
r+=min(right,left);
18+
prev=curr;
19+
}
20+
cout << r;
21+
}
22+
23+
24+
25+
26+
27+
28+
29+

0 commit comments

Comments
 (0)