-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
68 lines (57 loc) · 1.76 KB
/
Program.cs
File metadata and controls
68 lines (57 loc) · 1.76 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
namespace Grouping;
using csharpinterviewprep.LinkeredLists;
partial class Program
{
public static void Main(string[] args)
{
#region LeetCode
//TODO: SumTwo
Console.WriteLine(LeetCode.TwoSum.GetSums(new int[]{3,2,4}, 6));
#endregion
//Comment out below unneeded region blocks when you need to test specific test cases
#region FizzBuzz
CSharp.FizzBuzzer.FizzBuzz.fizzBuzzed(15);
#endregion
#region SockMerchant
Program.sockMerchant(7);
#endregion
#region Repeated String
RepeatingLetter.RepeatedString("ababa", 3);
#endregion
#region Least Path jumping clouds
LeastPath.JumpingClouds.CloudLeastPath(new List<int>{0, 0, 1 ,0 ,0, 1 ,0});
#endregion
}
// public static void Main(string[] args)
// {
// Console.WriteLine("Hellow");
// }
// Sock Merchant color pairing
public static int sockMerchant(int n)
{
#region Linker
MyList lister = new MyList();
lister.Add("1");
lister.Add("2");
lister.Add("3");
lister.Add("4");
lister.Add("5");
lister.Print();
//lister.Add("New Item");
#endregion
List<int> ar = new List<int>() { 1, 2, 1, 2, 1, 3, 2, 5, 5, 5, 3, 2, 1 };
var values = ar.GroupBy(q => q).Where(q => q.Count() >= 2).ToDictionary(m => m.Key, m => m.Count());
List<int> countPairs = new List<int>();
int countResult = 0;
if (values.Any())
{
foreach (KeyValuePair<int, int> i in values)
{
Console.WriteLine(i);
countResult += i.Value / 2;
}
}
Console.WriteLine(countResult);
return countResult;
}
}