217. Existing duplicate elements
Thought:
For the first time**C++**Write a question
Two methods:
- The first is sorting,Detect each time the first and the latter are equal;
- 第二种方法是Hash table,Determine whether the number has appeared for the second time。
existC++middle,Force buckle into the arraynums
in usevector
,So it can be used directlysort()
function。
I want to usePythonmiddle的字典(Hash table)if,Give to importunordered_set<int>
function新建Hash table,Re -usefind()
andend()
判断是否已经存exist。
Code:
1 | class Solution { |
1 | class Solution { |
1 | class Solution: |