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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:06:28+00:00 2026-05-29T10:06:28+00:00

Consider the following inputs: String[] input = {a9, aa9, a9a9, 99a99a}; What would be

  • 0

Consider the following inputs:

String[] input = {"a9", "aa9", "a9a9", "99a99a"};

What would be the most efficient way whilst using a StringBuilder to replace any digit directly prior to a nine with the next letter after it in the alphabet?

After processing these inputs the output should be:

String[] output = {"b9", "ab9", "b9b9", "99b99a"}

I’ve been scratching my head for a while and the StringBuilder.setCharAt was the best method I could think of.

Any advice or suggestions would be appreciated.

  • 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-29T10:06:29+00:00Added an answer on May 29, 2026 at 10:06 am

    Since you have to look at every character, you’ll never perform better than linear in the size of the buffer. So you can just do something like

    for (int i=1; buffer.length() ++i) // Note this starts at "1"
        if (buffer.charAt[i] == '9')
            buffer.setCharAt(i-1, buffer.getCharAt(i-1) + 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code snippet: String input = Print this; System.out.println(input.matches(\\bthis\\b)); Output false What
consider following scenario input string = WIPR.NS i have to replace this with WIPR2.NS
Consider the following Scala code def NOTImplementedIn[T<: AnyRef](t:T):String = throw new Exception(t.getClass.getName+: Input type
Consider the following mark-up input: * Line 1 * Line 2 :* Line 2.1
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider following program: static void Main (string[] args) { int i; uint ui; i
Consider the following String : 5|12345|value1|value2|value3|value4+5|777|value1|value2|value3|value4?5|777|value1|value2|value3|value4+ Here is how I want to split string,
I have following problem: Input String 1 : A[SPACE]B[SPACE]C[SPACE][SPACE]D[SPACE][SPACE]E Input String 2 : 1-
Consider the following: <label>Range from <input name='min_value'/> to <input name='max_value' /> </label> Is this
Consider the following code: public class ReadingTest { public void readAndPrint(String usingEncoding) throws Exception

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.