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

  • Home
  • SEARCH
  • 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 8886217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:30:17+00:00 2026-06-14T21:30:17+00:00

When I input a certain data item (character here), I can access the elements

  • 0

When I input a certain data item (character here), I can access the elements it relates to like:

When I input ‘A’, it gives me access to the values (2, 3, 4, 5), e.g.:

A - 2,3,4,5   
B - 6,7,9  
C - 10, 11, 12, 13  
D - 1,8
and so on...

Also that A, B, C, D could be any data item, int or even a string.

What I am thinking is, I can hold on a linear array and then each item in the array be the header for a linked list. Is this a correct and optimal solution to the above data structure required? Do we already have some data structure to do this?

  • 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-06-14T21:30:18+00:00Added an answer on June 14, 2026 at 9:30 pm

    The best solution is to use a Hash Table with an array (or list) in the table value.

    Here an example in Java using HashMap

    Map<String,Integer[]> theMap;
    theMap = new HashMap<String,Integer[]>();
    theMap.put("A",{2,3,4,5});
    theMap.put("B",{6,7,9});
    theMap.put("C",{10,11,12,13});
    theMap.put("D",{1,8});
    
    /* Access Values */
    int two = theMap.get("A")[0];
    

    You could also use ArrayList instead of arrays for your integers.

    The code would become as follows:

    ArrayList<Integer> listA = new ArrayList<Integer>();
        listA.add(2);
        listA.add(3);
        listA.add(4);
        listA.add(4);
    
    ArrayList<Integer> listB = new ArrayList<String>();
        listB.add(6);
        listB.add(7);
        listB.add(9);
    
    ArrayList<Integer> listC = new ArrayList<Integer>();
        listC.add(10);
        listC.add(11);
        listC.add(12);
        listC.add(13);
    
    ArrayList<Integer> listD = new ArrayList<Integer>();
        listD.add(1);
        listD.add(18);
    
        Map<String,List<Integer>> theMap;
        theMap = new HashMap<String,List<Integer>>();
        theMap.put("A",listA);
        theMap.put("B",listB);
        theMap.put("C",listC);
        theMap.put("D",listD);
    
        /* Access Values */
        int two = theMap.get("A").get(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the input elements form a certain div inside a form
I want to add a class to certain input or label elements in a
I am trying to remove certain values from an array containing input fields in
I'm trying to get all the input elements from a certain form from jQuery
What I would like to get some input on is how to remove certain
I'm torn between two implementations of a certain data structure, and input from the
Given a data structure that contains an array of JavaScript objects, how can I
since DAO layer is typically responsible for accessing data from DB given certain input
I have a computation that calculates a resulting percentage based on certain input. But
I'm writing some code that handles logging xml data and I would like to

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.