File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+
3+ class Solution {
4+ public:
5+ bool containsDuplicate (vector<int >& nums) {
6+ sort (nums.begin (), nums.end ());
7+
8+ for (int i = 0 ; i < nums.size () - 1 ; i++)
9+ if (nums[i] == nums[i+1 ])
10+ return true ;
11+
12+ return false ;
13+ }
14+ };
15+
16+ // ์ฒซ ์๋ ๋ฐ ํ๋ฆฐ ํ์ด
17+ // ํ๋ฆฐ ์ด์ :
18+ // leetcode๋ ์ฒ์ ํ์ด๋ณด๋๋ฐ, ๋ฐฑ์ค๋ณด๋ค ์๊ฐ ์ ํ์ด ์๊ฒฉํจ
19+ // -> 20์ต ๋ฐฐ์ด ์ ์ธํ๋๊ฒ๋ง์ผ๋ก๋ ์๊ฐ์ด๊ณผ ๋ฐ์
20+ //
21+ // class Solution {
22+ // public:
23+ // bool containsDuplicate(vector<int>& nums) {
24+ // vector<bool> check(2'000'000'001, false);
25+ // int offset = 1'000'000'000;
26+
27+ // for(int i = 0; i < nums.size(); i++) {
28+ // int idx = nums[i] + offset;
29+
30+ // if(check[idx] == true)
31+ // return true;
32+ // check[idx] = true;
33+ // }
34+ // return false;
35+ // }
36+ // };
You canโt perform that action at this time.
0 commit comments