+ 13
Complete the challenge.
Print the maximum combinations that can occur for the given letters. NOTE: Letters have to be taken in a character array and no digits or special characters are allowed. If so, warn the user to enter correct input. Ex: input - A B C output - A, B, C, AB, BC, AC, ABC. The order of the letters doesn't matter I.e., AB and BA are same. No need print them again. I think u people understand it better now. If u have any queries ask me. Send the answer as early as possible. Bkz, I need this in my project.
10 Answers
+ 9
Can anyone be able to solve this in Java.
Bkz, my project is done in Java.
+ 8
Thanks for ur response.
I'll give it a try.
+ 6
Solved it. Have a look. And it's with Java... But only I have not checked for only letters. You can do that easily I think.
https://code.sololearn.com/cb4XohDmM9Tw/?ref=app
+ 5
very cool challenge! will indeed give it a try
+ 5
I think condition is correct. Combination is a term of math. See https://en.wikipedia.org/wiki/Combination?wprov=sfla1 . I have other question to author. Is input array can include repeatly characters?
+ 5
I think this program needs recursion and will be best with that. Wait I am trying it...
+ 3
I am not that good in Java but this link may help you
https://www.programcreek.com/2014/03/leetcode-combinations-java/
+ 2
Hm, I think something is wrong with your condition.
The maximum amount of combinations for A B C:
A, B, C, AB, BA, AC, CA, BC, CB, ABC = 10. Am I right?
//Edit
Also ACB, BAC, BCA, CBA and CAB. So the maximum is 15
+ 2
Finally made it
https://code.sololearn.com/cDFX1236sg4F/?ref=app
+ 1
Hi, what you can do is: if there are n letters, calculate in binary all the numbers between 0 and 111...1, where there are n 1's. Then, for each one of them (you can think they have n digits, maybe starting with some 0's), if in the position i appears a 1, then print the i-th letter given by the user, else, not print it. That way, you will get all the possible combinations of letters, including the void (if you don't want it, start in 000...01 instead 000...0).
Hope it's useful!