# 0527. Word Abbreviation

<https://leetcode.com/problems/word-abbreviation>

## Description

Given an array of **distinct** strings `words`, return *the minimal possible **abbreviations** for every word*.

The following are the rules for a string abbreviation:

1. Begin with the first character, and then the number of characters abbreviated, followed by the last character.
2. If there is any conflict and more than one word shares the same abbreviation, a longer prefix is used instead of only the first character until making the map from word to abbreviation become unique. In other words, a final abbreviation cannot map to more than one original word.
3. If the abbreviation does not make the word shorter, then keep it as the original.

**Example 1:**

```
**Input:** words = ["like","god","internal","me","internet","interval","intension","face","intrusion"]
**Output:** ["l2e","god","internal","me","i6t","interval","inte4n","f2e","intr4n"]
```

**Example 2:**

```
**Input:** words = ["aa","aaa"]
**Output:** ["aa","aaa"]
```

**Constraints:**

* `1 <= words.length <= 400`
* `2 <= words[i].length <= 400`
* `words[i]` consists of lowercase English letters.
* All the strings of `words` are **unique**.

## ac

```java
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jaywin.gitbook.io/leetcode/solutions/0527-word-abbreviation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
