From 7c60dee83b436e8e8a667bf9f191beced8de4fc3 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Mon, 10 Mar 2025 00:36:13 -0600 Subject: chore: move cpp and rust code to directory --- other/orderly_queue.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 other/orderly_queue.cpp (limited to 'other/orderly_queue.cpp') diff --git a/other/orderly_queue.cpp b/other/orderly_queue.cpp new file mode 100644 index 0000000..23053d2 --- /dev/null +++ b/other/orderly_queue.cpp @@ -0,0 +1,20 @@ +#include "leetcode.h" + +class Solution { +public: + string orderlyQueue(string s, int k) { + if (k > 1) { + sort(s.begin(), s.end()); + return s; + } + string ans = s; + for (int i = 1; i < s.size(); i++) + ans = min(ans, s.substr(i) + s.substr(0, i)); + return ans; + } +}; + +int main() { + Solution obj; + cout << obj.orderlyQueue("cba", 1); +} -- cgit v1.2.3