0

[case 1] 2 input parameters
'abc', 'tre'
output value
'atbrce'

[case 2] 3 input parameters
'gbd', 'student'
output
'gsbtdudent'

how to solve shuffle string merge?

3 Answers3

0

The suffling is easy:

var rnd = new Random();
string st1="abc";
string str2="tre";
string unsuffled = str1+str2;
string shuffled = new string(unsuffled.OrderBy(r => rnd.Next()).ToArray());

refrence Link

Community
  • 1
  • 1
Durgesh Pandey
  • 2,314
  • 4
  • 29
  • 43
0

This is what do you want

List<char> list1 = "gbd".ToList<char>();
            List<char> list2 = "student".ToList<char>();
            string result = string.Empty;
            for (int i = 0; i <  list2.Count(); i++)
            {
                try
                {
                    result = result + list1[i] + list2[i];
                }
            catch
            {
                result = result + list2[i];
            }
        }
Vecchiasignora
  • 1,275
  • 7
  • 6
0

Can you do this:

string a = "hell";
string b = "tata";

var concatString = String.Join("", a.Select((x, i) => x + "" + b[i]));
Gauravsa
  • 6,330
  • 2
  • 21
  • 30