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, 2022 in C# by jyoti
• 1,240 points
359 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, 2022 in C# by rajiv
• 1,620 points
421 views
0 votes
0 answers

C# Potential Interview Question…Too hard?

Determine which Foo method will be invoked ...READ MORE

Sep 27, 2022 in C# by krishna
• 2,820 points
411 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, 2022 in C# by rajiv
• 1,620 points
437 views
0 votes
1 answer

Is a Library a project or a C# source code file in Visual Studio?

A library project is a collection of ...READ MORE

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

Good C# interview questions book

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

answered Jun 7, 2022 in C# by rajiv
• 1,620 points
380 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, 2022 in C# by rajiv
• 1,620 points
517 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,140 points
5,723 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
1,114 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
11,310 views
0 votes
1 answer

SQLite.Net not being able to create text file in Win IoT Library!

That exception comes when access limited to ...READ MORE

answered Aug 3, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,013 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP