diff --git a/cpp/2203/220329.cpp b/cpp/2203/220329.cpp new file mode 100644 index 0000000..25eb92d --- /dev/null +++ b/cpp/2203/220329.cpp @@ -0,0 +1,15 @@ +#include +#include + +class Solution { +public: + static int findDuplicate(const std::vector& nums) { + std::bitset<100008> s; + for (int i : nums) { + if (s[i]) + return i; + s[i] = true; + } + return -1; + } +}; diff --git a/cpp/2203/CMakeLists.txt b/cpp/2203/CMakeLists.txt index baf4248..ba66ab5 100644 --- a/cpp/2203/CMakeLists.txt +++ b/cpp/2203/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2203) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2203 220328.cpp) +ADD_EXECUTABLE(2203 220329.cpp)