712. Minimum ASCII Delete Sum for Two Strings
题目描述
Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.
|
|
|
|
Note:
- 0 < s1.length, s2.length <= 1000.
- All elements of each string will have an ASCII value in [97, 122].
题目大意
给定两个字符串,删除其中一些字符使得两个字符相等。
删除字符ASCII和最小的。
解题思路
动态规划
使用数组dp
记录s1
前i
项ASCII和。
遍历s2
, 使用tmp
记录删除字符ASCII和最小。添加规则为:
|
|
代码
|
|