Skip to content

Commit c9c72d1

Browse files
authored
Update unique-word-abbreviation.cpp
1 parent 81c6baf commit c9c72d1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

C++/unique-word-abbreviation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ValidWordAbbr {
2121
unordered_map<string, unordered_set<string>> lookup_;
2222

2323
string abbreviation(const string& word) {
24+
if (word.length() <= 2) {
25+
return word;
26+
}
2427
return word.front() + to_string(word.length()) + word.back();
2528
}
2629
};

0 commit comments

Comments
 (0)