diff --git a/3518/solution.cpp b/3518/solution.cpp index efb16eb..45fbf10 100644 --- a/3518/solution.cpp +++ b/3518/solution.cpp @@ -4,25 +4,19 @@ #include #include -using std::set; -using std::string; -using std::ranges::next_permutation; -using std::ranges::reverse; -using std::ranges::sort; - class Solution { public: - string smallestPalindrome(string s, int k) { + std::string smallestPalindrome(std::string s, int k) { - string half = s.substr(0, s.size() / 2); + std::string half = s.substr(0, s.size() / 2); - sort(half); + std::ranges::sort(half); - set permutations; + std::set permutations; do { permutations.insert(half); - } while (next_permutation(half).found); + } while (std::ranges::next_permutation(half).found); if (permutations.size() > std::numeric_limits::max()) { throw std::overflow_error("Number of permutations exceeds int limit"); @@ -30,14 +24,14 @@ public: int size = static_cast(permutations.size()); if (k > size) { - return string(); + return std::string(); } auto it = permutations.begin(); advance(it, k - 1); - string mirroredHalf = *it; - reverse(mirroredHalf); + std::string mirroredHalf = *it; + std::ranges::reverse(mirroredHalf); return *it + mirroredHalf; }