ReverseString a C interview-question

0 votes

I was asked for my 'input' on a piece of code written by a young programmer in an interview. They hinted at a potential issue and stated that it would be frequently employed on huge strings.

public string ReverseString(string sz)
{
    string result = string.Empty;
    for(int i = sz.Length-1; i>=0; i--)
    {
      result += sz[i]
    }
    return result;
}

I was unable to locate it. There were no issues that I noticed. In retrospect, I could have suggested the user should resize, but C# doesn't appear to have one (I'm a C++ guy).

I ended up putting things like utilise an iterator if possible, [x] in containers could not be random access, therefore it would be sluggish, and so on. and a few other things However, I specifically stated that I had never had to optimise C# code, indicating that my reasoning did not fail me during the interview.

I'm curious as to what the issue is with this code; do you see it?

Jun 11 in C# by jyoti
• 1,240 points
7 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C#

0 votes
1 answer

C# Potential Interview Question…Too hard?

This isn't a question I'd ask in ...READ MORE

answered Jun 7 in C# by rajiv
• 1,620 points
16 views
0 votes
1 answer

C# - Can someone please show me a very simple example of Interfaces

Take this as example interface IFlyable { ...READ MORE

answered May 30 in C# by rajiv
• 1,620 points
14 views
0 votes
1 answer
0 votes
1 answer

Good C# interview questions book

If you're simply familiar with the foundations ...READ MORE

answered Jun 7 in C# by rajiv
• 1,620 points
10 views
0 votes
1 answer

Need a fast C# tutorial for (short-term) non-.Net programmers

First use this link http://www.thinkingparallel.com/2007/03/06/c-vs-c-a-checklist-from-a-c-programmers-point-of-view/ Second, ask them ...READ MORE

answered Jun 9 in C# by rajiv
• 1,620 points
5 views
0 votes
1 answer

Encapsulation of subclasses from a constructor in C#

If you think about it in terms ...READ MORE

answered Jun 11 in C# by pranav
• 2,320 points
11 views
0 votes
3 answers

Trying to upload files using Selenium(C#)

You can try using Javascript Executor to ...READ MORE

answered Aug 23, 2019 in Selenium by Abha
• 28,100 points
4,468 views
0 votes
1 answer

Deploy my Windows 10 IOT core application locally!

Of course, you, can! That is, in ...READ MORE

answered Jul 17, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
499 views
+6 votes
16 answers

How do backend of these really cool games work?

Most of the games these days don't ...READ MORE

answered Jul 19, 2018 in Career Counselling by Kalgi
• 52,350 points
7,252 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP