A conversion
Practice
4.2 (150 votes)
Ready
Brute Force search
Easy Medium
Approved
Breadth First search
Problem
9% Success 1807 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Again a simple task from Oz! He has given you two strings \(STR1\) and \(STR2\). Each character of both strings is from the set {A, B, C, D, E, F, G, H, I, J}. You can perform 3 types of conversions on string \(STR1\) :

  • Replace a character(except 'J') by next character from the set. i.e "ABE" to "ACE"
  • Replace a character(except 'A') by previous character from the set. i.e "ABE" to "ABD"
  • Swap any two characters. i.e "ABE" to "EBA"

Now you have to convert \(STR1\) into \(STR2\) using minimum number of conversions. Output the minimum number of conversions required.

Input:
First line of the input contains a single integer T denoting the number of test cases.
Each test case consist of two lines. First line contains \(STR1\) and second line contains \(STR2\).

Output:
For each test case, output minimum number of conversions required.

Constraints:
1 ≤ T ≤ 10
1 ≤ |\(STR1\)| ≤ 8
|\(STR1\)| = |\(STR2\)|

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:30
Tags:
MediumGeometryMathematicsLine-sweepOpenApproved
Points:30
14 votes
Tags:
Dynamic ProgrammingEasyRecursion
Points:30
1 votes
Tags:
RecruitHiringMinimum spanning treeAlgorithmsEasy-MediumGreedy algorithmReadyApproved