A string such as "word" contains the following abbreviations:

["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]

Given a target string and a set of strings in a dictionary, find an abbreviation of this target string with the smallest possible length such that it does not conflict with abbreviations of the strings in the dictionary.

Each number or letter in the abbreviation is considered length = 1. For example, the abbreviation "a32bc" has length = 4.

Note:

  • In the case of multiple answers as shown in the second example below, you may return any one of them.
  • Assume length of target string = m, and dictionary size = n. You may assume that m ≤ 21, n ≤ 1000, and log2(n) + m ≤ 20.

Examples:

"apple", ["blade"] -> "a4" (because "5" or "4e" conflicts with "blade")

"apple", ["plain", "amber", "blade"] -> "1p3" (other valid answers include "ap3", "a3e", "2p2", "3le", "3l1").

411. Minimum Unique Word Abbreviation的更多相关文章

  1. [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  2. Leetcode: Minimum Unique Word Abbreviation

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  3. [Locked] Unique Word Abbreviation

    Unique Word Abbreviation An abbreviation of a word follows the form <first letter><number&g ...

  4. Leetcode Unique Word Abbreviation

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  5. 288. Unique Word Abbreviation

    题目: An abbreviation of a word follows the form <first letter><number><last letter> ...

  6. Unique Word Abbreviation

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  7. [LeetCode] Unique Word Abbreviation 独特的单词缩写

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  8. [Swift]LeetCode288. 唯一单词缩写 $ Unique Word Abbreviation

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

  9. Unique Word Abbreviation -- LeetCode

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

随机推荐

  1. 滴滴快车,安全把你带到凡科安全知识h5大赛

    滴滴出行提出"安全第一.体验第二.效率第三"的可持续发展宗旨.近期,滴滴出行还推广了"安全带"宣传,包括明星夫妻CP安全带姿势和明星后排安全带语音播报等,来提升 ...

  2. JavaScript判断、循环、Map、Set

     本文是笔者在看廖雪峰老师JavaScript教程时的个人总结      一些判断条件                 JavaScript把null.undefined.0.NaN和空字符串''视为 ...

  3. Unity3D 中的协程

    若干文章: 1.Coroutine,你究竟干了什么? 2.Radical Coroutines 3.Extended Unity Coroutines

  4. PHP5.3.3+Apache2.2.16+MySQL5.1.49

    轻松配置PHP5.3.3+Apache2.2.16+MySQL5.1.49,下面是有详细的步骤说明.   第一步:下载安装的文件 1. MySQL:下载地址mysql-5.1.49-win32.msi ...

  5. SQL Server Management Studio 已停止工作 异常错误

    找到类似环境下sql的路径 D:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ 复制出 Ss ...

  6. 用orb-slam2跑RGB-D Example中的TUM Dataset

    链接在此:https://github.com/raulmur/ORB_SLAM2 1.按照要求下载数据集,我下载的是rgbd_dataset_freiburg2_pioneer_360,将其解压到你 ...

  7. python date

    三天前 datetime.datetime.now() - datetime.timedelta(days=3)

  8. mysql 5.7配置文件参数详解

    read_buffer_size 默认大小:128KB 最大:2GB 最小:8KB 增量:必须为4KB的整数倍,如果配置的不是整数倍,会向下取整 用途: 1.MyISAM表顺序扫描提供的缓存 2.所有 ...

  9. oracle dbms_JOB

    添加一个任务,怎么老是报错 [SQL] DECLARE job1 number; begin dbms_job.submit(job1,'RESTUDY_SCORE_IMPORT',sysdate,' ...

  10. Linux 设备驱动程序 proc seq

    不能再简化 #include<linux/module.h> #include<linux/init.h> #include<linux/seq_file.h> # ...