I want to remove range of slice from slice like remove "A", "B" from "A" to "Z", but I want to make it efficient (I don't know why in Go but in Python we can use hashmap).
The code below is the closest I can get but there are edge cases I miss:
func removeString(listOri []string, targetDelete []string) []string {
newitems := []string{}
for i := range listOri {
for j := range targetDelete {
if listOri [i] != targetDelete[j] {
newitems = append(newitems, listOri [i])
}
}
}
return newitems
}
listOriginal := []string{"A", "B", "C", "D"}
listDelete := []string{"A", "B"}
listNew := removeString(listOriginal, listDelete)
result = "A","B","C","C","D","D"