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 8730739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:05:13+00:00 2026-06-13T09:05:13+00:00

I recently faced some technical interviews, the questions were: Q.1 Two Strings are given

  • 0

I recently faced some technical interviews, the questions were:

Q.1 Two Strings are given “Hello” & “World”. Print Unique
Characters Present in first and not in the second string

OUTPUT: He.

My Answer: Compare each character of one string to with every other character of second, not optimal at all (wrong, obviously).

Q.2 ABCABBABCAB, OUTPUT:4A5B2C`, (basically count occurrence of each character)
do this in one pass, not multiple traversal in string, there where other
Again do this in optimal way.

Similarly, there where few other question too..

Question which arises at core to me is:

  • Which data structure from collection framework will help me to handle such scenarios in most optimum way; and

  • Which particular data structure from Java Collection Framework to be used when and why?

Also, If there are books for such topics, do tell

Any Help-Books, References and Links will be of great help in learning and understanding.

IMPORTANT: I need real time scenarios, where which the data structure is implemented

I have studied, Collection API, not throughly, but a summarised idea of hierachy and major data structure classes. i know how to use them, but where and why exactly use them eludes me?

  • 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-13T09:05:15+00:00Added an answer on June 13, 2026 at 9:05 am
    public class G {
    public static void main(String[] args) {
        new G().printCharacterCount("ABCABBABCAB");
        System.out.println();
        new G().printUniqueCharacters("Hello", "world");
    }
    
    void printUniqueCharacters(String a, String b) {
        Set<Character> set = new HashSet<Character>();
        for (int i = 0; i < a.length(); i++)
            set.add(a.charAt(i));
    
        for (int i = 0; i < b.length(); i++)
            set.remove(b.charAt(i));
    
        for (Character c : set)
            System.out.print(c);
    }
    
    void printCharacterCount(String a) {
        Map<Character, Integer> map = new TreeMap<Character, Integer>();
    
        for(int i = 0; i < a.length(); i++) {
            char c = a.charAt(i);
            if(!map.containsKey(c))
                map.put(c, 0);
    
            map.put(c, map.get(c) +1);
        }
    
        for(char c : map.keySet()) {
            System.out.print(map.get(c) + "" + c);
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I faced few interview questions.The interviewer asked the to give the detailed answer.
This is an interview question I faced recently. Given an array of 1 and
recently I faced some problems concerning the use of fftw and it's c2c transformation
Recently I've faced weird issue. I have two simple queries where one of them
I faced this question in an interview recently. The original question was Given a
I recently faced a problem with determining browsers' support for certain DOM features. One
I'm new in developing iOS app. So I've recently faced a problem with localization
Recently we faced the issue of flowscope values not being set across the flow,
I have recently been faced with a rather odd task, one result being the
Recently I had faced compiling errors in a c++ code I wrote so I've

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.