我有以下情況,我需要從數組中刪除一些元素。我有元素的數組如下:從數組中刪除一些元素
[
"white & blue", "white & red", "white & black",
"blue & white", "blue & red", "blue & black",
"red & white", "red & blue", "red & black",
"black & white", "black & blue", "black & red",
"white", "blue", "red", "black",
"white & blue & red & black"
]
我需要僅這些要素轉換到這一點的數組:在上面的例子
[
"white & blue", "white & red", "white & black",
"blue & red", "blue & black",
"red & black",
"white", "blue", "red", "black",
"white & blue & red & black"
]
,元件"white & blue"
和"blue & white"
需要被視爲是一樣的,只保留其中一個並刪除另一個。
我還沒找到有效的方法。我如何做到這一點?
這有太多的部件和過於寬泛,因爲它是目前。在高層次上,您需要解析字符串,將結果輸出標準化,過濾掉重複項並將結果返回到原始格式。你應該弄清楚哪些是造成你的麻煩,並提出關於他們的個別問題。 –