我有一個包含n
數組的數組,每個數組都包含不同數量的字符串元素。從多個陣列中發現差異和缺失元素
每個字符串包含一個關鍵字如evar#
,event#
,prop#
(其中#
是一個數字)。
我需要做到以下幾點:從一個字符串,它是與其他陣列中的至少一個
- 回報所有的關鍵詞至少其他陣列之一。
這裏是一個包含3個數組的數組的例子:
[
[
"overwrite value of evar1 with page_url_query 'int_cmp'",
"set event1 to custom value '1'",
"set event2 to custom value '1'",
"overwrite value of evar2 with page_url",
"overwrite value of evar3 with contextdata.user_id",
"set event4 to eventid",
"set event3 to eventid"
],
[
"overwrite value of prop3 with contextdata.phase",
"overwrite value of prop2 with contextdata.room",
"set event1 to custom value '1'",
"set event2 to eventid",
"overwrite value of evar5 with contextdata.queue",
"set event4 to eventid",
"overwrite value of evar6 with contextdata.audience",
"set event3 to eventid",
"set event5 to custom value '1'"
],
[
"overwrite value of evar4 with contextdata.no_challenges",
"overwrite value of prop3 with contextdata.user_type",
"overwrite value of evar7 with contextdata.interaction",
"set event2 to custom value '1'",
"set event3 to eventid",
"set event4 to eventid",
"set event1 to custom value '1'",
"set event5 to custom value '1'"
]
]
和響應應包含以下陣列:
[evar1, event2, evar2, evar3, prop3, prop2, evar6, event5, evar4, evar7]
請讓我知道如果我需要提供更多信息。我願意接受任何建議...
以後編輯:
我實現了一個解決方案,但我認爲它需要一些優化。我會很感激,如果有人幫助我...
有關工作代碼評論和優化請求[代碼評論](http://codereview.stackexc hange.com/)是適當的地方。然而,我已將您的問題提交給我的解決方案。 – Redu