Microsoft Interview Question
1,273 Interview Reviews |
Back to all Microsoft Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Development Engineer Intern at Microsoft:
Reverse all the characters in a string before you encounter an 'x'. abcdxdd - > dcbaxdd
See more for this Microsoft Software Development Engineer Intern Interview
Helpful Question?
Yes |
No
Inappropriate?



0 of 0 people found this helpful
by Andrey:
using System.Linq;
namespace ReverseString
{
class Program
{
static void Main()
{
string s = "abcdxdd";
int reverseEnd = s.IndexOf('x');
if (reverseEnd < 0)
reverseEnd = 0;
string subAr1 = new string(s.Substring(0, reverseEnd).Reverse().ToArray());
string subAr2 = s.Substring(reverseEnd);
s = String.Concat(subAr1, subAr2);
Console.WriteLine(s);
}
}
}