-
1346. Check If N and Its Double Exist릿코드(LEETCODE) 2020. 2. 14. 14:00반응형
https://leetcode.com/problems/check-if-n-and-its-double-exist/
Source
class Solution { public: bool checkIfExist(vector<int>& arr) { unordered_set<int> s; for (int n : arr) { if (s.count(2 * n) || (n % 2 == 0 && s.count(n / 2))) return true; s.insert(n); } return false; } };
반응형'릿코드(LEETCODE)' 카테고리의 다른 글
118. Pascal's Triangle (0) 2020.02.14 1347. Minimum Number of Steps to Make Two Strings Anagram (0) 2020.02.14 1025. Divisor Game (0) 2020.02.14 53. Maximum Subarray (0) 2020.02.13 392. Is Subsequence (0) 2020.02.13