Can a set have duplicate elements?

前端 未结 4 1893
醉酒成梦
醉酒成梦 2021-02-07 14:25

I have been asked a question that is a little ambiguous for my coursework.

The array of strings is regarded as a set, i.e. unordered.

I\'m not

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 15:18

    Let A={1,2,2,3,4,5,6,7,...} and B={1,2,3,4,5,6,7,...} then any element in A is in B and any element in B is in A ==> A contains B and B contains A ==> A=B. So of course sets can have duplicate elements, it's just that the one with duplicate elements would end up being exactly the same as the one without duplicate elements.

提交回复
热议问题