From 54ec17501f4c9ac480d69ce21809224d8ba3eb86 Mon Sep 17 00:00:00 2001 From: Bluemin <130892773+bluemincoder@users.noreply.github.com> Date: Sat, 13 Apr 2024 12:07:39 +0530 Subject: [PATCH] chore: day_19 --- hard/day_19/problem.txt | 24 ++++++++++++++++++++++++ hard/day_19/sample_test_cases.txt | 22 ++++++++++++++++++++++ hard/day_19/solution.cpp | 1 + 3 files changed, 47 insertions(+) create mode 100644 hard/day_19/problem.txt create mode 100644 hard/day_19/sample_test_cases.txt create mode 100644 hard/day_19/solution.cpp diff --git a/hard/day_19/problem.txt b/hard/day_19/problem.txt new file mode 100644 index 0000000..4f3054c --- /dev/null +++ b/hard/day_19/problem.txt @@ -0,0 +1,24 @@ +In the realm of beautiful strings, a string is deemed beautiful if it satisfies two crucial conditions: + +1. Every character within the string must be either A, B, or C. +2. No two adjacent characters are identical. + +For instance, AB and BCAC qualify as beautiful strings, whereas BB and CBAAC fall short of the beauty standard. + +You're entrusted with a beautiful string s . Your task: to morph it into the lexicographically smallest possible string while preserving its beauty. To achieve this, you're allowed to perform a single operation repeatedly: + +Operation: +- Swap two adjacent characters in s , ensuring that the string remains beautiful even after the swap. + +You're presented with t test cases, each requiring its own solution. + +Input: +- Each test case segment commences with a line containing a single integer t ( 1 ≤ t ≤ 10^5 ) denoting the number of sets of input data. +- Following this are descriptions of the test cases. +- The first line of each test case holds the beautiful string s , where |s| represents its length ( 1 ≤ |s| ≤ 10^6 ). + +Output: +- Your output should consist of t lines. +- Each line should contain the lexicographically smallest string that s can transform into for the corresponding test case. + +Feel free to swap and shuffle your way through the test cases, crafting the most aesthetically pleasing strings! \ No newline at end of file diff --git a/hard/day_19/sample_test_cases.txt b/hard/day_19/sample_test_cases.txt new file mode 100644 index 0000000..de594e6 --- /dev/null +++ b/hard/day_19/sample_test_cases.txt @@ -0,0 +1,22 @@ +Example + +Input +8 +CAB +ACBCB +B +AC +BACBA +BABABA +ABCBCAC +CBABACABCBABABC + +Output +ABC +ABCBC +B +AC +ABABC +BABABA +ABCACBC +ABABACBCACBCBAB \ No newline at end of file diff --git a/hard/day_19/solution.cpp b/hard/day_19/solution.cpp new file mode 100644 index 0000000..8d3ad8d --- /dev/null +++ b/hard/day_19/solution.cpp @@ -0,0 +1 @@ +//write your code here \ No newline at end of file