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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:43:26+00:00 2026-05-21T08:43:26+00:00

In the one dimensional array S , There might be any number of elements

  • 0

In the one dimensional array S , There might be any number of elements that belong to the set

U:{A,B,C,D,E}  

and repetition is allowed.
Example :

S  = {E,B,D,C,A,D,A,E,E,D,B,B,A,C} 

Question is:

What is the most efficient way in which I can determine the shortest range/path that contains all the elements belonging to set U ,In any given array S ? keep in mind the array can’t be sorted.

In the above example the shortest path is that connecting the first 5 elements of the array S.

EDIT :
1) The Number Of Elements of set U isn’t constant.

Thanks in advance.

  • 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-21T08:43:27+00:00Added an answer on May 21, 2026 at 8:43 am

    Interesting homework, but you still have to code yourself.

    Good thing is you have not told us which language you use, so I take it as a sign as you’ve decided to code yourself, which is good.


    My best try so far:

    Have 2 pointers for the sub string (range), one for the start (smaller index) of the range and one for the end (larger index). Both point to the beginning of the array first.

    Have a list for how many ABCDEs are in the range respectively.

    Iterate end from left to right.

    For every character, increment the number for the character in the list. If the result (incremented how many) > 1(, see if start points to the same character. If yes, move start forward and minus 1, and) while start points to a character the related number for which > 1, move start forward and minus 1.

    If ABCDE in the list all >= 1, then we’ve found a candidate range. Compare it to the shortest length (if any), and if it is smaller, update the shortest length and record the index for the start of the new shortest range.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to specify a one dimensional array in a ini file.
I have a one-dimensional array of strings in JavaScript that I'd like to turn
noob question on c#: how to create a one-dimensional dynamic array? And how to
Is there any built-in functionality in vba to get unique values from a one-dimensional
This is basically a restatement of this question: Java: Multi-dimensional array vs. One-dimensional but
How can I create an empty one-dimensional string array?
I have a multi-dimensional array, which basically consists of one sub-array for each year.
I have a multi dimensional array in PHP. $f = array('one' => array(*doesntmatter*), two
I have a multi-dimensional array, no problem. How do I interrogator one of the
I am having some problems with manipulating a one dimensional string array in VB.NET

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.