|  | 
| 1 | 1 | # [2273.Find Resultant Array After Removing Anagrams][title] | 
| 2 | 2 | 
 | 
| 3 |  | -> [!WARNING|style:flat] | 
| 4 |  | -> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm) | 
| 5 |  | -
 | 
| 6 | 3 | ## Description | 
|  | 4 | +You are given a **0-indexed** string array `words`, where `words[i]` consists of lowercase English letters. | 
|  | 5 | + | 
|  | 6 | +In one operation, select any index `i` such that `0 < i < words.length` and words[i - 1] and words[i] are **anagrams**, and **delete** `words[i]` from `words`. Keep performing this operation as long as you can select an index that satisfies the conditions. | 
|  | 7 | + | 
|  | 8 | +Return `words` after performing all operations. It can be shown that selecting the indices for each operation in **any** arbitrary order will lead to the same result. | 
|  | 9 | + | 
|  | 10 | +An **Anagrams** is a word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once. For example, `"dacb"` is an anagram of `"abdc"`. | 
| 7 | 11 | 
 | 
| 8 | 12 | **Example 1:** | 
| 9 | 13 | 
 | 
| 10 | 14 | ``` | 
| 11 |  | -Input: a = "11", b = "1" | 
| 12 |  | -Output: "100" | 
|  | 15 | +Input: words = ["abba","baba","bbaa","cd","cd"] | 
|  | 16 | +Output: ["abba","cd"] | 
|  | 17 | +Explanation: | 
|  | 18 | +One of the ways we can obtain the resultant array is by using the following operations: | 
|  | 19 | +- Since words[2] = "bbaa" and words[1] = "baba" are anagrams, we choose index 2 and delete words[2]. | 
|  | 20 | +  Now words = ["abba","baba","cd","cd"]. | 
|  | 21 | +- Since words[1] = "baba" and words[0] = "abba" are anagrams, we choose index 1 and delete words[1]. | 
|  | 22 | +  Now words = ["abba","cd","cd"]. | 
|  | 23 | +- Since words[2] = "cd" and words[1] = "cd" are anagrams, we choose index 2 and delete words[2]. | 
|  | 24 | +  Now words = ["abba","cd"]. | 
|  | 25 | +We can no longer perform any operations, so ["abba","cd"] is the final answer. | 
| 13 | 26 | ``` | 
| 14 | 27 | 
 | 
| 15 |  | -## 题意 | 
| 16 |  | -> ... | 
|  | 28 | +**Example 2:** | 
| 17 | 29 | 
 | 
| 18 |  | -## 题解 | 
| 19 |  | - | 
| 20 |  | -### 思路1 | 
| 21 |  | -> ... | 
| 22 |  | -Find Resultant Array After Removing Anagrams | 
| 23 |  | -```go | 
| 24 | 30 | ``` | 
| 25 |  | - | 
|  | 31 | +Input: words = ["a","b","c","d","e"] | 
|  | 32 | +Output: ["a","b","c","d","e"] | 
|  | 33 | +Explanation: | 
|  | 34 | +No two adjacent strings in words are anagrams of each other, so no operations are performed. | 
|  | 35 | +``` | 
| 26 | 36 | 
 | 
| 27 | 37 | ## 结语 | 
| 28 | 38 | 
 | 
|  | 
0 commit comments