aboutsummaryrefslogtreecommitdiff
path: root/other/orderly_queue.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
committerJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
commit7c60dee83b436e8e8a667bf9f191beced8de4fc3 (patch)
treeeb7a24ee2067f92245c57bb118e85a1baf15df50 /other/orderly_queue.cpp
parent5d7cdc215e4ba1ec4cbb24c084cccb5e5e641468 (diff)
downloadleetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.tar.gz
leetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.zip
chore: move cpp and rust code to directory
Diffstat (limited to 'other/orderly_queue.cpp')
-rw-r--r--other/orderly_queue.cpp20
1 files changed, 20 insertions, 0 deletions
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);
+}