( Problem A ) Pikachu and the Game of Strings
Practice
3.9 (60 votes)
Algorithms
Easy
Greedy algorithms
Problem
90% Success 9661 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Pikachu has recently learnt a new move $$ s $$. He knows he can work hard and convert it into a stronger move $$ t $$. Both the moves $$ s $$ and $$ t $$ contain the same number of letters.

In a single day, Pikachu can increase any letter of move $$ s $$ by one, that is, in a single day, he can convert letter $$A$$ to $$B$$, $$ C$$ to $$ D $$, $$M $$ to $$N$$ and so on. He can also convert letter $$Z$$ to letter $$A$$. 

Pikachu just realized he also has a hidden ability. It can help him increase any letter of move $$ s $$ by $$ 13 $$,  that is, in a single day, he can convert letter $$A$$ to letter $$N$$, $$B$$ into $$O$$, $$M$$ into $$Z$$ , $$ O$$ into $$B$$ and so on.  

Now Pikachu wants to know the minimum number of days in which he can convert the move $$ s $$ into move $$ t $$  ?
 

Constraints:

  • \(1\le |s|=|t|\le 10^5\)
  • s and consists of uppercase English letters only

Input format:

  • First line contains an integer $$ n $$, the length of strings $$ s $$ and $$ t $$
  • Second line contains string $$ s $$ of length $$ n $$
  • Third line contains string $$ t $$ of length $$ n $$ 

Output format:

  • Output single line containing the minimum number of days required

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
3 votes
Tags:
Greedy AlgorithmsBasics of Greedy AlgorithmsSortingAlgorithmsMerge Sort
Points:10
9 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Points:10
9 votes
Tags:
Greedy AlgorithmsAlgorithmsStringBasics of Greedy Algorithms