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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:25:39+00:00 2026-05-16T06:25:39+00:00

I have following problem: Input String 1 : A[SPACE]B[SPACE]C[SPACE][SPACE]D[SPACE][SPACE]E Input String 2 : 1-

  • 0

I have following problem:

Input String 1 : “A[SPACE]B[SPACE]C[SPACE][SPACE]D[SPACE][SPACE]E”
Input String 2 : “1-” OR “1,2” OR “3-“

If Input String 2 is 1- then I am supposed to return string from first word

If the input string is 3- then i am supposed to return string from 3rd word,
If the input string is 1,2 then I am supposed to return word 1 and 2

One cannot assume that more than one space is delimiter

For example

3- should return C[SPACE][SPACE]D[SPACE][SPACE]E

PLEASE CONSIDER [SPACE] as actual space character

  • 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-16T06:25:40+00:00Added an answer on May 16, 2026 at 6:25 am

    You didn’t say what language so… Java!
    It’s hacky, and assumes that the inputs are valid, but probably a good starting point

    public void foo(String input, String q) {
      //First clean up the input string so that all tokens are delimited by one space
      input = input.replaceAll(" *", " ");
    
      String[] inputTokens = input.split(",");       
      String[] queries = q.split(",");
      for (String query : queries) {
        if (query.endsWith(-)) {
          query = query.replace("-", "");
          for (int i = Integer.parseInt(query), i <= inputTokens.length; i++) {
            System.out.println(inputTokens[i]);
          }
        } else {
          System.out.println(inputTokens[Integer.parseInt(query)]);
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem, from c++ I send huge string[] to java. huge
I have the following problem - from the server side I get a string
i have the following problem Given a string, return a cleaned string where adjacent
I can't understand how to solve the following problem: I have input string aaaabaa
i have the following problem with that code in my html tag: <div id=searchbar><input
I have following problem, Code: String a=Yeahh, I have no a idea what's happening
A have the following input string: string input = Ta005000000000000000000Tb001700000000000000000Sa005000000000000000000 + Sb002500000000000000000F 00000000000000000I 00000000000000000N
I have an input string in the following format String input = 00IG356001110002005064007000000; Characters
I have a problem trying to transform a given input string to a given
I have following problem: I have to make a ASP.NET Webapplication with a two-row

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.