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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:44:18+00:00 2026-05-16T23:44:18+00:00

Here is my requirement: Input: Random String of sufficiently long ex: fdjhkajajkfdj Output: fdj

  • 0

Here is my requirement:

  • Input: Random String of sufficiently long ex: fdjhkajajkfdj
  • Output: fdj has a 2 occurences and separated by x chars

I want to put all three letter words in an array and check if they are the same
Eg:

a[0] = fdj
a[1] = djh
a[2] = jhk
a[3] = hka
a[4] = kaj
.
.
.
a[n] =fdj

My answer is a[0] and a[n] matches, may be more than 2 occurances.

Question: So what kind of array should I use which is optimal in this situation. I am using Java (and also python). I was thinking of Dict.

  • 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-16T23:44:19+00:00Added an answer on May 16, 2026 at 11:44 pm

    In Java you could use the Map interface ( http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.html )

    I would use HashMap so that the key is the 3 letter word and the value is the count of occurances. Here’s some sample pseudo code

    HashMap<String, int> wordCountMap = new HashMap<String, int>();
    for(....) // for each 3 letter word in the input
    {
        String word = ...; // current three letter word
        if(wordCountMap.containsKey(word))
            wordCountMap.put(word, wordCountMap.get(word)++);
        else
            wordCountMap.put(word, 1);
    }
    

    Then you can loop through the key/value pairs and return their occurance count.

    To return the number of characters between the words, you can do this separately after counting the occurances by using String manipulation (see String.indexOf). Pseudo code for this is….

    String orginalInput = "fdjhkajajkfdj";
    String word = "fdj";
    int firstOccurance = originalInput.indexOf();
    int secondOccurance = originalInput.indexOf(firstOccurance+1);
    int charsInBetween = secondOccurance - firstOccurance - 3; // difference in indices minus length of word
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My requirement is on input change i want to check number of non empty
Here is my requirement. My sample input document is like below. (I have added
Slightly unusual requirement here, which unfortunately is down to a poor table design a
I am creating a installer using WIX, The requirement here is that when the
Here is my requirement. I need to unzip a zip file and store it
Here is simplified version of my requirement I have a java class say Processor
First question here so hello everyone. The requirement I'm working on is a small
Here we have an interesting real-world algorithm requirement involving colors. N Pretty Colors :
I'm looking for a Perl string checksum function with the following properties: Input: Unicode
Our company has people in every catastrophic event here in the U.S. and parts

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.