-
Notifications
You must be signed in to change notification settings - Fork 0
/
69-FindDuplcateCharacters.cs
42 lines (38 loc) · 1.09 KB
/
69-FindDuplcateCharacters.cs
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
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HackerRank
{
internal class FindDuplcateCharacters_Result
{
public string DuplicateString(string str)
{
string result = string.Empty;
for(int i = 0; i < str.Length-1; i++)
{
for(int j = i+1; j < str.Length; j++)
{
if (str[i] == str[j] && !result.Contains(str[i]))
{
result=result+ str[j];
}
}
}
return result;
}
}
internal class FindDuplcateCharacters_Solution
{
public void Input()
{
//string str = "improper";
//output=pr
string str = "ESTATEMENTS";
//output=EST
string duplicateCharacters = new FindDuplcateCharacters_Result().DuplicateString(str);
Console.WriteLine($"duplicate characters in {str} are: {duplicateCharacters}");
}
}
}