码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Bold Words in String 字符串中的加粗单词

时间:2018-03-09 01:40:56      阅读:432      评论:0      收藏:0      [点我收藏+]

标签:more   length   turned   nbsp   note   har   bin   ring   etc   

 

Given a set of keywords words and a string S, make all appearances of all keywords in S bold. Any letters between <b> and </b> tags become bold.

The returned string should use the least number of tags possible, and of course the tags should form a valid combination.

For example, given that words = ["ab", "bc"] and S = "aabcd", we should return "a<b>abc</b>d". Note that returning "a<b>a<b>b</b>c</b>d" would use more tags, so it is incorrect.

Note:

  1. words has length in range [0, 50].
  2. words[i] has length in range [1, 10].
  3. S has length in range [0, 500].
  4. All characters in words[i] and S are lowercase letters.

 

s

 

[LeetCode] Bold Words in String 字符串中的加粗单词

标签:more   length   turned   nbsp   note   har   bin   ring   etc   

原文地址:https://www.cnblogs.com/grandyang/p/8531642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!