From 4a43ef5ae5f47dac2fd51898e440358888ba7408 Mon Sep 17 00:00:00 2001 From: mhhung Date: Thu, 14 Aug 2025 15:44:41 +0800 Subject: [PATCH] feat : add c# solution --- 202508/2264 largestGoodInteger/C#/C#.sln | 24 +++++++ 202508/2264 largestGoodInteger/C#/Program.cs | 63 +++++++++++++++++++ .../C#/largestGoodInteger.csproj | 10 +++ 3 files changed, 97 insertions(+) create mode 100644 202508/2264 largestGoodInteger/C#/C#.sln create mode 100644 202508/2264 largestGoodInteger/C#/Program.cs create mode 100644 202508/2264 largestGoodInteger/C#/largestGoodInteger.csproj diff --git a/202508/2264 largestGoodInteger/C#/C#.sln b/202508/2264 largestGoodInteger/C#/C#.sln new file mode 100644 index 0000000..8e77df2 --- /dev/null +++ b/202508/2264 largestGoodInteger/C#/C#.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "largestGoodInteger", "largestGoodInteger.csproj", "{DF73131C-3A52-FFDC-7C0C-19190AA3E331}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF73131C-3A52-FFDC-7C0C-19190AA3E331}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF73131C-3A52-FFDC-7C0C-19190AA3E331}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF73131C-3A52-FFDC-7C0C-19190AA3E331}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF73131C-3A52-FFDC-7C0C-19190AA3E331}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E9F3A871-90C4-4B8E-81E2-B0AF873694BF} + EndGlobalSection +EndGlobal diff --git a/202508/2264 largestGoodInteger/C#/Program.cs b/202508/2264 largestGoodInteger/C#/Program.cs new file mode 100644 index 0000000..3e0853f --- /dev/null +++ b/202508/2264 largestGoodInteger/C#/Program.cs @@ -0,0 +1,63 @@ +public class Solution { + public string LargestGoodInteger(string num) + { + // var count = 0; + // char lastNum = 'a'; + // var numList = new List(); + // for (var i = 0; i < num.Length; i++) + // { + // if (num[i] == lastNum) + // { + // count++; + // if (count == 3) + // { + // numList.Add(int.Parse(num[i].ToString())); + // } + // } + // else + // { + // count = 1; + // } + + // lastNum = num[i]; + // } + + // if (numList.Count == 0) + // { + // return ""; + // } + // else + // { + // var a = numList.Max().ToString(); + // return $"{a}{a}{a}"; + // } + + string max = ""; + + for (int i = 0; i < num.Length - 2; i++) + { + if (num[i] == num[i + 1] && num[i] == num[i + 2]) + { + string current = $"{num[i]}{num[i]}{num[i]}"; + + if (max == "") max = current; + else + { + if (int.Parse(current) > int.Parse(max)) + max = current; + } + } + } + return max; + } +} + +class program +{ + static void Main() + { + var solution = new Solution(); + + Console.WriteLine(solution.LargestGoodInteger("6777133339")); + } +} \ No newline at end of file diff --git a/202508/2264 largestGoodInteger/C#/largestGoodInteger.csproj b/202508/2264 largestGoodInteger/C#/largestGoodInteger.csproj new file mode 100644 index 0000000..2150e37 --- /dev/null +++ b/202508/2264 largestGoodInteger/C#/largestGoodInteger.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + +