Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com

Letter Case Permutation

Moderate
0/80
Average time to solve is 15m
profile
Contributed by
5 upvotes
Asked in companies
UberOlaMicrosoft

Problem statement

You are given a string 'S'. Your task is to find an array of all possible strings in any order that can be formed by transforming every letter individually to the lowercase or the uppercase.

Note:

1. You can print the array in any order.

2. The string 'S' only contains English alphabets and digits.
Detailed explanation ( Input/output format, Notes, Images )
Constraints:
1 <= T <= 100
1 <= |S| <= 12

Where |S| denotes the length of string 'S'.

Time Limit: 1 sec.
Sample Input 1:
1
a1b
Sample Output 1:
A1B A1b a1B a1b
Explanation for sample input 1:
These are the four strings that we can get after transforming every letter individually to be lowercase or uppercase.
Sample Input 2:
1
0
Sample Output 2:
0
Explanation for sample input 2:
There is no alphabet in the string, so we get the output same as the input string.
Full screen
Console