Skip to content

Commit

Permalink
chore: day_19
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemincoder authored Apr 13, 2024
1 parent 6884cdd commit 54ec175
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
24 changes: 24 additions & 0 deletions hard/day_19/problem.txt
Original file line number Diff line number Diff line change
@@ -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!
22 changes: 22 additions & 0 deletions hard/day_19/sample_test_cases.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Example

Input
8
CAB
ACBCB
B
AC
BACBA
BABABA
ABCBCAC
CBABACABCBABABC

Output
ABC
ABCBC
B
AC
ABABC
BABABA
ABCACBC
ABABACBCACBCBAB
1 change: 1 addition & 0 deletions hard/day_19/solution.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//write your code here

0 comments on commit 54ec175

Please sign in to comment.