Question Index

Write a program to return the list of all the words possible with the characters provided. The list should be sorted in ascending order. Do not use String or StringBuffer or Arrays or any other advanced classes. Only use character arrays for solving this.

Input (Char Array) Output (Two Dimensional Char Array)
{M, Y} {{M, Y},
{Y, M}}
{B, A, T} {{A, B, T},
{A, T, B},
{B, A, T},
{B, T, A},
{T, A, B},
{T, B, A}}
{M, O, N} {{M, N, O},
{M, O, N},
{N, M, O},
{N, O, M},
{O, M, N},
{O, N, M}}
{J, U, B, A} {{A, B, J, U},
{A, B, U, J},
{A, J, B, U},
{A, J, U, B},
{A, U, B, J},
{A, U, J, B},
{B, A, J, U},
{B, A, U, J},
{B, J, A, U},
{B, J, U, A},
{B, U, A, J},
{B, U, J, A},
{J, A, B, U},
{J, A, U, B},
{J, B, A, U},
{J, B, U, A},
{J, U, A, B},
{J, U, B, A},
{U, A, B, J},
{U, A, J, B},
{U, B, A, J},
{U, B, J, A},
{U, J, A, B},
{U, J, B, A}}

class GetAllCharCombinations

{    public static void main(String s[])
        char input[] = {'B', 'A', 'T'};
        char[][] words = getAllCombinations(input);
        for (char[] word : words) {
        for (char letter : word) {


public static char[][] getAllCombinations(char word[]) {
//Write code here to get all the combinations of the given word.

//If required write any additional methods here



Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App