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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:06:57+00:00 2026-05-15T11:06:57+00:00

The input is string[] like below. "CSE111: CSE110 MATH101" "CSE110:" I need to order

  • 0

The input is string[] like below.

"CSE111: CSE110 MATH101"

"CSE110:"

I need to order the strings based on some logic. For example my output should be a string[] like

"CSE110","MATH122","CSE111"

My question is

  1. While scanning through the input array, if one string is picked to be the first string of the output array, then how do I skip all occurrences of that particular string, while I continue to process the string[] for the second output string etc..

Eg:

Input:

"CSE111: CSE110 MATH101"

"CSE110:"

If CSE110 is picked to be the first string in the output, then when I scan through the input string[] for the second string to be a part of output, I should not consider CSE110.

How can I achieve this? The answer I am looking forward to is something like:

  1. Store the input in a string[]
  2. loop through the strings one by one using strtok or stringstream >> operator.
  3. Once the first string is found …blah blah blah ….

Hope my question is clear enough. I will be glad to provide more details.

Edit1:More Explanation

The strings represent the order in which the classes need to taken . If a class has pre-requisite , the pre-requisite has to be taken first. ie. if Input is

"CSE111: CSE110 MATH101"
"CSE110:"

The class CSE111 has a pre-requisite of CSE110 MATH101 . So I need to consider first CSE1110(No Pre-requisite) – MATH101((No Pre-requisite) and then CSE111 . (Further Ties can broken in alphabetical order. )
I hope this helps..

  • 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-15T11:06:58+00:00Added an answer on May 15, 2026 at 11:06 am

    I hopefully got it now: For a string of the form A: B C D, the course A has B, C, and D as prerequisites.

    In that case you want a mapping from a course to its prerequisites, e.g.:

    typedef std::set<std::string> CourseSet;
    typedef std::map<std::string, CourseSet> Prerequisites;
    

    Now you can fill a Prerequisites by tokenizing, using the first part as the key and a CourseSet as the value.

    As it seems that you just want one of the possible orders for all courses in the input, you could then do the following:

    • complete the prerequisites for the courses (i.e. include the courses they indirectly depend on)
    • now a>b if a has b as a prerequisite
    • if b doesn’t have a as a prerequisite use e.g. the lexicographical order
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear All, I have 2 input string 1)stack,over,flow 2)stack/over,flow,com I would like to print
I have the below situation Case 1: Input : X(P)~AK,X(MV)~AK Replace with: AP Output:
The URL below, the first content in the chosen answer describes JSP hiding. Hidden
I need to add a form to my existing application i have it all
I'd like to start using unit tests, but I'm having a hard time understanding
I have a form with some validations set in entity metadata class. and then
Below, on initial load (Edit), everything displays fine. However, when I POST (Action below),
Can you check if this is a browser cache problem? I have this scenario,
I want to write a stored procedure that queries XML files after I have
I've just set up a small R&D MVC2 project, and I've basically used only

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.