`{"id":"989fc426-47bd-4ca0-8923-7625f0b7b916","name":"Minimum Ascii Delete Sum For Two Strings","description":"1. You are given two strings S1 and S2.\r\n2. You have to make these two strings equal by deleting characters. You can delete characters from any of the two strings.\r\n3. The cost of deleting a character from any string is the ASCII value of that character.\r\n4. You have to find the minimum ASCII sum of deleted characters. ","inputFormat":"Two Strings S1 and S2","outputFormat":"A number representing the minimum ASCII sum of deleted characters.","constraints":"1 &lt;= length of strings S1 and S2 &lt;= 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) {\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\tSystem.out.println(solution(s1, s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"sea\r\neat","sampleOutput":"231\r\n","questionVideo":"https://www.youtube.com/embed/GPePWKCEy24?end=142","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":"edcbd3ca-cab1-472f-ae7c-b0f2a73a6850","name":"Minimum Ascii Delete Sum For Two Strings","slug":"minimum-ascii-delete-sum-for-two-strings","type":1}],"next":{"id":"1105b482-81e8-4328-9dfa-e9794bc73afa","name":"Minimum ascii delete sum for two strings MCQ","type":0,"slug":"minimum-ascii-delete-sum-for-two-strings-mcq"},"prev":{"id":"6fd3675b-136f-4d09-83f8-40cd2ff9179b","name":"Longest Repeating Subsequence","type":3,"slug":"longest-repeating-subsequence"}}}`

# Minimum Ascii Delete Sum For Two Strings

1. You are given two strings S1 and S2. 2. You have to make these two strings equal by deleting characters. You can delete characters from any of the two strings. 3. The cost of deleting a character from any string is the ASCII value of that character. 4. You have to find the minimum ASCII sum of deleted characters.

`{"id":"989fc426-47bd-4ca0-8923-7625f0b7b916","name":"Minimum Ascii Delete Sum For Two Strings","description":"1. You are given two strings S1 and S2.\r\n2. You have to make these two strings equal by deleting characters. You can delete characters from any of the two strings.\r\n3. The cost of deleting a character from any string is the ASCII value of that character.\r\n4. You have to find the minimum ASCII sum of deleted characters. ","inputFormat":"Two Strings S1 and S2","outputFormat":"A number representing the minimum ASCII sum of deleted characters.","constraints":"1 &lt;= length of strings S1 and S2 &lt;= 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) {\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\tSystem.out.println(solution(s1, s2));\r\n\t}\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"sea\r\neat","sampleOutput":"231\r\n","questionVideo":"https://www.youtube.com/embed/GPePWKCEy24?end=142","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":"edcbd3ca-cab1-472f-ae7c-b0f2a73a6850","name":"Minimum Ascii Delete Sum For Two Strings","slug":"minimum-ascii-delete-sum-for-two-strings","type":1}],"next":{"id":"1105b482-81e8-4328-9dfa-e9794bc73afa","name":"Minimum ascii delete sum for two strings MCQ","type":0,"slug":"minimum-ascii-delete-sum-for-two-strings-mcq"},"prev":{"id":"6fd3675b-136f-4d09-83f8-40cd2ff9179b","name":"Longest Repeating Subsequence","type":3,"slug":"longest-repeating-subsequence"}}}`

Editor

# Minimum Ascii Delete Sum For Two Strings

medium

1. You are given two strings S1 and S2. 2. You have to make these two strings equal by deleting characters. You can delete characters from any of the two strings. 3. The cost of deleting a character from any string is the ASCII value of that character. 4. You have to find the minimum ASCII sum of deleted characters.

## Constraints

1 <= length of strings S1 and S2 <= 1000

## Format

### Input

Two Strings S1 and S2

### Output

A number representing the minimum ASCII sum of deleted characters.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}sea eat```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}231 ```

Question Video

Discussions

Show Discussion

Related Resources