feat: add solution for smallest palindromic rearrangement ii
- add problem 3518 implementation - add build configuration with debug and release modes - add test cases and examples - add makefile for problem-specific build workflow
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#include "solution.cpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
Solution s;
|
||||
|
||||
// Example 1
|
||||
{
|
||||
std::string result = s.smallestPalindrome("abba", 2);
|
||||
assert(result == "baab");
|
||||
}
|
||||
|
||||
// Example 2
|
||||
{
|
||||
std::string result = s.smallestPalindrome("aa", 2);
|
||||
assert(result == "");
|
||||
}
|
||||
|
||||
// Example 3
|
||||
{
|
||||
std::string result = s.smallestPalindrome("bacab", 1);
|
||||
assert(result == "abcba");
|
||||
}
|
||||
|
||||
// Additional tests
|
||||
|
||||
// Single palindrome
|
||||
{
|
||||
std::string result = s.smallestPalindrome("aaa", 1);
|
||||
assert(result == "aaa");
|
||||
}
|
||||
|
||||
// k exceeds number of permutations
|
||||
{
|
||||
std::string result = s.smallestPalindrome("aabb", 3);
|
||||
assert(result == "");
|
||||
}
|
||||
|
||||
// Two different characters
|
||||
{
|
||||
std::string result = s.smallestPalindrome("aabbcc", 1);
|
||||
assert(result == "abccba");
|
||||
}
|
||||
|
||||
// Already sorted palindrome
|
||||
{
|
||||
std::string result = s.smallestPalindrome("abcba", 2);
|
||||
assert(result == "bacab");
|
||||
}
|
||||
|
||||
std::cout << "All tests passed!\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user