{"id":"1bfb69b6-795d-4c46-92a2-208a6dd2e9bf","name":"Minimum Cost To Make Two Strings Identical","description":"1. You are given two strings S1, S2, and two numbers x and y.\r\n2. The cost of deleting a character from S1 is x and the cost of deleting a character from S2 is y.\r\n3. You can delete characters from both the strings.\r\n4. You have to find the minimum cost required to make the given two strings identical.","inputFormat":"Two Strings S1, S2\r\nTwo numbers x and y","outputFormat":"A number representing the minimum cost of making the given two strings identical.","constraints":"1 <= length of strings S1 and S2 <= 1000\r\n1 <= x,y <= 1000","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String s1, String s2, int c1, int c2) {\r\n\t\t// write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tint x = scn.nextInt();\r\n\t\tint y = scn.nextInt();\r\n\t\tSystem.out.println(solution(s1, s2,x, y));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"sea\r\neat\r\n10\r\n7","sampleOutput":"17\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"e132d023-faf4-4b0b-863e-e1614bb9b0d4","name":"Minimum Cost To Make Two Strings Identical","slug":"minimum-cost-to-make-two-strings-identical","type":1}],"next":{"id":"8473049a-4a3b-42d9-aade-934573928276","name":"Minimum cost to make two strings identical MCQ","type":0,"slug":"minimum-cost-to-make-two-strings-identical-mcq"},"prev":{"id":"726d1d4e-c7a0-41e9-beaa-69b41c3a7b1d","name":"EDIT DISTANCE","type":3,"slug":"edit-distance"}}}

Minimum Cost To Make Two Strings Identical

1. You are given two strings S1, S2, and two numbers x and y. 2. The cost of deleting a character from S1 is x and the cost of deleting a character from S2 is y. 3. You can delete characters from both the strings. 4. You have to find the minimum cost required to make the given two strings identical.

{"id":"1bfb69b6-795d-4c46-92a2-208a6dd2e9bf","name":"Minimum Cost To Make Two Strings Identical","description":"1. You are given two strings S1, S2, and two numbers x and y.\r\n2. The cost of deleting a character from S1 is x and the cost of deleting a character from S2 is y.\r\n3. You can delete characters from both the strings.\r\n4. You have to find the minimum cost required to make the given two strings identical.","inputFormat":"Two Strings S1, S2\r\nTwo numbers x and y","outputFormat":"A number representing the minimum cost of making the given two strings identical.","constraints":"1 <= length of strings S1 and S2 <= 1000\r\n1 <= x,y <= 1000","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String s1, String s2, int c1, int c2) {\r\n\t\t// write your code here\r\n\r\n\t\treturn 0;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString s1 = scn.next();\r\n\t\tString s2 = scn.next();\r\n\t\tint x = scn.nextInt();\r\n\t\tint y = scn.nextInt();\r\n\t\tSystem.out.println(solution(s1, s2,x, y));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"sea\r\neat\r\n10\r\n7","sampleOutput":"17\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"e132d023-faf4-4b0b-863e-e1614bb9b0d4","name":"Minimum Cost To Make Two Strings Identical","slug":"minimum-cost-to-make-two-strings-identical","type":1}],"next":{"id":"8473049a-4a3b-42d9-aade-934573928276","name":"Minimum cost to make two strings identical MCQ","type":0,"slug":"minimum-cost-to-make-two-strings-identical-mcq"},"prev":{"id":"726d1d4e-c7a0-41e9-beaa-69b41c3a7b1d","name":"EDIT DISTANCE","type":3,"slug":"edit-distance"}}}
plane

Editor


Loading...

Minimum Cost To Make Two Strings Identical

easy

1. You are given two strings S1, S2, and two numbers x and y. 2. The cost of deleting a character from S1 is x and the cost of deleting a character from S2 is y. 3. You can delete characters from both the strings. 4. You have to find the minimum cost required to make the given two strings identical.

Constraints

1 <= length of strings S1 and S2 <= 1000 1 <= x,y <= 1000

Format

Input

Two Strings S1, S2 Two numbers x and y

Output

A number representing the minimum cost of making the given two strings identical.

Example

Sample Input

sea eat 10 7

Sample Output

17

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode