-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwoStringsToOneSortedUniqueString.cs
More file actions
37 lines (31 loc) · 1013 Bytes
/
TwoStringsToOneSortedUniqueString.cs
File metadata and controls
37 lines (31 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
namespace Algorithms
{
public class Program
{
public static void Main(string[] args)
{
string mergedString = MergeSortUnique("xyaabbbccccdefww", "xxxxyyyyabklmopq");
Console.WriteLine(mergedString);
}
public static string MergeSortUnique(string first, string second)
{
string firstandsecond = first + second;
int[] alphabets = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
foreach(char c in firstandsecond)
{
alphabets[((int)c) - 97] = 1;
}
string final = "";
for(int counter = 0; counter < 26 ; counter++)
{
if(alphabets[counter] == 1)
{
final += (char)(counter + 97);
}
}
return final;
}
}
}