Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:58:49+00:00 2026-05-30T17:58:49+00:00

I have an array of characters c[][] with different mappings to each index. For

  • 0

I have an array of characters c[][] with different mappings to each index.
For example:

{'a', 'b', 'c', 'd', 'e', 'f' } {'g', 'h', 'i' }

I need to return all the possible character combinations for this array as a string.
That meaning, for the above character array, I should return:
“ag”, “ah”, “ai”, “bg”, “bh”, “bi”, “cg”, “ch”, “ci”, etc.
It would be easy to do this for a character array of only two things like above, but if there are more arrays, then I do not know what to do…
Which is what I am asking you all to help me with! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:58:50+00:00Added an answer on May 30, 2026 at 5:58 pm

    For two arrays two nested loops should do:

    for (int i = 0 ; i != c[0].length ; i++) {
        for (int j = 0 ; j != c[1].length ; j++) {
            System.out.writeln(""+c[0][i]+c[1][j]);
        }
    }
    

    For more nesting you would need a recursive or an equivalent stack-based solution.

    void combos(int pos, char[][] c, String soFar) {
        if (pos == c.length) {
             System.out.writeln(soFar);
             return;
        }
        for (int i = 0 ; i != c[pos].length ; i++) {
            combos(pos+1, c, soFar + c[pos][i]);
        }
    }
    

    Call this recursive function from your main() like this:

    combos(0, c, "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that contains some UTF-8 characters from different languages. Every entry
Say I have an array of arbitrary size holding single characters. I want to
I have a simple function which takes an array of characters as an argument,
I have a char array buffer that I am using to store characters that
I have a character array and I'm trying to figure out if it matches
Is a string actually a character array (is-a), or does it have a character
I have a method (C++) that returns a character and takes an array of
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
In some RightToLeft languages (Like Arabic, Persian, Urdu, etc) each letter can have different
So I have an array of strings, and all of the strings are using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.