标签:tco combine cee sed etc substr leetcode get over
Given a string s and a list of strings dict, you need to add a closed pair of bold tag <b>
and </b>
to wrap the substrings in s that exist in dict. If two such substrings overlap, you need to wrap them together by only one pair of closed bold tag. Also, if two substrings wrapped by bold tags are consecutive, you need to combine them.
Example 1:
Input: s = "abcxyz123" dict = ["abc","123"] Output: "<b>abc</b>xyz<b>123</b>"
Example 2:
Input: s = "aaabbcc" dict = ["aaa","aab","bc"] Output: "<b>aaabbc</b>c"
Note:
s
[LeetCode] Add Bold Tag in String 字符串中增添加粗标签
标签:tco combine cee sed etc substr leetcode get over
原文地址:http://www.cnblogs.com/grandyang/p/7043394.html