I am having trouble to come with a approach and code for this problem, can somebody help me out?
Here is the question
Antas has a garden where plants are planted in a row. Each plant is represented by a character which can be a letter or a number. However, his father does not like the design and he wants to change it to a new design. This new design is also represented by characters. To change the garden, he can take the following actions:
- Plant a sapling
- Uproot a sapling
- Replace the plant with another
Each of the actions have an associated cost which are as follows:
- Planting - $100
- Uproot - $100
- Replacing - $100
Help him find the minimum cost for changing the garden to the new design.
Input Format
The first line contains t which gives the number of rows in the garden. Then for each row, there are two lines which represent the following:
1. The first line contains a string of characters that represent the old design.
2. The second line contains a string of characters that represent the new design.
Output Format
The output contains r lines where ith line contains the minimum cost of changing ith row from old design to new design.
Constraints
1 <= r <= 10000
1 <=n <= 100, where n is the length of the string of characters representing the plants
Sample Input
2
mobile
phone
help
all
d
Sample Output
$500.00
$300.00
Explanation
For the first row, it will need to plant one ‘p’ plant which costs $100, then replacing ‘m’ to ‘h’, which
costs $100, no change for plant ‘o’, replacing ‘b’ with ‘n’ which costs $100, then uprooting ‘i’ and ‘l’
which costs $100 each. In total , the minimum cost for changing row 1 to new design needs
$500.