Company: Infosys sp role_26april
Difficulty: medium
You are given two strings, A and B . Your task is to align their characters in sequence to minimize the total cost. Every character in both strings must be accounted for: each must either be paired with a character from the other string or be part of a contiguous removal. You can perform the following operations: Match/Mismatch: Pair a character from string A with a character from string B . If the characters are the same, the cost for this pair is 0 . If the characters are different, the cost for this pair is Penalty_Match . Contiguous Removal: You can skip a continuous sequence of characters from either string A or string B . If a continuous sequence of length L is removed from one string, the cost for that specific sequence is L^2 . Find the minimum total cost to align strings A and B . Input Format The first line contains an integer, Penalty_Match , denoting the cost when two paired characters do not match. The second line contains a string, A . The third line contains a string, B