From 721a548a1e5723559c804bdf20da1a772fd28b01 Mon Sep 17 00:00:00 2001 From: Eat-Swap Date: Mon, 13 Jun 2022 00:56:31 +0800 Subject: [PATCH] add: 220613-CN [cpp] --- cpp/2206/220613-CN.cpp | 14 ++++++++++++++ cpp/2206/CMakeLists.txt | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 cpp/2206/220613-CN.cpp diff --git a/cpp/2206/220613-CN.cpp b/cpp/2206/220613-CN.cpp new file mode 100644 index 0000000..65125c0 --- /dev/null +++ b/cpp/2206/220613-CN.cpp @@ -0,0 +1,14 @@ +#include +#include + +class Solution { +public: + static int heightChecker(const std::vector& h) { + auto x = h; + std::stable_sort(x.begin(), x.end()); + int ret = 0; + for (int i = 0; i < x.size(); ++i) + ret += (x[i] != h[i]); + return ret; + } +}; diff --git a/cpp/2206/CMakeLists.txt b/cpp/2206/CMakeLists.txt index 9e8f7b2..09d14d6 100644 --- a/cpp/2206/CMakeLists.txt +++ b/cpp/2206/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2206) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2206 220612.cpp) +ADD_EXECUTABLE(2206 220613-CN.cpp)