/* Problem: https://leetcode.com/problems/letter-case-permutation/ */ #include "lib_leetcode.h" #include #include #include std::vector solution(const std::string input) { std::vector perms = {""}; for (const char c : input) { for (std::size_t i = 0, upto = perms.size(); i < upto; i++) { if (std::isalpha(c)) perms.push_back(perms[i] + (char)std::toupper(c)); perms[i] += std::tolower(c); } } return perms; } int main() { std::cout << solution("a1b2") << '\n' << solution("3z4") << '\n' << solution("mQe") << '\n' << solution("03fH") << '\n'; }