320.Generalized-Abbreviation
320. Generalized Abbreviation
题目地址
https://leetcode.com/problems/generalized-abbreviation/
题目描述
Write a function to generate the generalized abbreviations of a word.
Note: The order of the output does not matter.
Example:
Input: "word"
Output:
["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]代码
Approach #1 Backtracking
Time: O(n 2^n) && Space: O(n)
Approach #2 Bit Manipulation
Time: O(n 2^n) && Space: O(n)
Previous317.Shortest-Distance-from-All-BuildingsNext323.Number-of-Connected-Components-in-an-Undirected-Graph
Last updated
Was this helpful?