如何使用Golang找到一个数组中不在另一个数组中的元素?

huangapple go评论80阅读模式
英文:

how to find the elements from an array which are not in another array using golang?

问题

我有两个数组A和B,A["anusha", "kirthy", "reema"],B["anusha", "raju", "sudha"]。我需要获取数组A中不在数组B中的元素。在golang中,结果将是["kirthy", "reema"]。请帮助我。

英文:

i have two array A and B ,A["anusha","kirthy","reema"],B["anusha","raju","sudha"].i need to get the elements of an array A which are not in array B .result will be ["kirthy","reema"] in golang .please help me

答案1

得分: 2

这是一个解决你问题的游乐场(快速而简单,可能有更好的解决方案,但这个可以工作):https://play.golang.org/p/7vTXLtaGNh

这个问题听起来像是一个简单的作业,稍微动动脑筋,你应该可以自己解决的。

英文:

Here's a Playground solving your problem (Quick and Dirty, there may be better solutions out there, but this one works.): https://play.golang.org/p/7vTXLtaGNh

This Problem sounds like a simple homework, with a bit tinkering you could've solved it yourself i guess.

huangapple
  • 本文由 发表于 2017年8月24日 18:41:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/45859471.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定