As a follow up to Unique Abbreviations

  • 0

    In my interview, as a follow up, i was asked the following question:

    An abbreviation can be anything now (alpha-numeric). each number is considered length = 1 and each character is considered length = 1.

    "internationalization" -> 20, i19, 19n, i18n
    "localization" -> 12, l11, 11n, l10n
    “dog” -> 3, d2, 2d, d1g
    “accessibility” -> 13, a12, 12y, a11y, ac11 
    “automatically” -> 13, a12, 12y, a11y,  au11
    Abbreviation lengths:
    internationalization -> 20 -> len = 1
    localization -> l11 -> len = 2
    automatically -> a11y -> len = 3

    For a given dictionary of words, find all the unique abbreviations with the least length.

    List<String> findUniqueAbbreviations( List<String> dict )

    Dictionary: internationalization, localization, dog, accessibility, automatically

    Result: word -> abbreviations
    "internationalization" -> 20
    "localization" -> 12
    "dog" -> 3
    "accessibility" -> ac11 
    "automatically" -> au11
     selecting abbreviations like "13", "a12", "12y", "a11y" for either 
     accessibility or automatically will break the "unique" rule

  • 0
    This post is deleted!

  • 0

    Hi @FindingWaldo, I also have heard about this question. For your example, I think "accessibility" can be abbreviated as "6i6", which is shorter than "ac11", is that right?

  • 0

    6i6 -> is length = 3

    ac11 -> length = 3

    So doesn't necessarily be shorter

  • 0

    @1337c0d3r - how do u convert this to a Leetcode OJ Problem ?

  • 0

    I don't understand how did people make sense out of this question.
    What do you mean by "An abbreviation can be anything now (alpha-numeric)"? Can the abbr of every word be its length, i.e. a number? Then the length of the abbr is 1. So every word has an abbr with least length (=1).

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.