Question
Write simple python/java program and also explain the logic because i am crying so much and not able to understand anything. Generating Sequence: You are
Write simple python/java program and also explain the logic because i am crying so much and not able to understand anything.
Generating Sequence: You are given two strings A of length N and B of length M. These strings contain lowercase English alphabets. You are also given an integer K. You can change the character of x string A to any other characters y. The cost of this conversion is abs( ASCII(x)- ASCII(y) ). Find the minimum cost required such that the length of the longest common subsequence (LCS) of A and B is at least K.
Note:
- A subsequence of A string can be obtained by deleting zero or more characters in A.
- The longest common subsequence of two strings of A and B is a subsequence of A and B and has the maximum length among all strings that are a subsequence of A and B that would be multiple subsequences for two provided strings for example an LCS of vera and eats is ea.
Input Format:
- The first line contains an integer T denoting the number of test cases for each test case.
- The first line of each test case contains three space-separated integers N, M, and K.
- The next line of each test case contains a string A.
- The next line of each test case contains a string B.
Output format: For each test case, print the minimum cost required in a new line.
Constraints
1 T 10
1 N, M 200
0 K min( N, M )
Example:
Input: 2 5 4 3 abcba acyx 3 3 3 abc abc Output: 22 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started