From 959f8a68613338bc48d12fe7fdd3ed93a1ce858e Mon Sep 17 00:00:00 2001 From: MH Hung Date: Wed, 24 Sep 2025 09:34:13 +0800 Subject: [PATCH] remove: legacy solutions --- legacy/2264 largestGoodInteger/C#/C#.sln | 24 ---- legacy/2264 largestGoodInteger/C#/Program.cs | 63 ---------- .../C#/largestGoodInteger.csproj | 10 -- legacy/2264 largestGoodInteger/GO/main.go | 23 ---- .../C#/2438 ProductQueries.sln | 24 ---- .../C#/ProductQueries.csproj | 10 -- legacy/2438 ProductQueries/C#/Program.cs | 69 ----------- legacy/2438 ProductQueries/description.md | 5 - legacy/2787 numberOfWays/C#/C#.sln | 24 ---- legacy/2787 numberOfWays/C#/Program.cs | 48 -------- .../2787 numberOfWays/C#/numberOfWays.csproj | 10 -- legacy/3000 areaOfMaxDiagonal/C#/Program.cs | 38 ------ .../C#/areaOfMaxDiagonal.csproj | 10 -- legacy/3000 areaOfMaxDiagonal/GO/main.go | 27 ---- legacy/3195 minimumArea/C#/C#.sln | 24 ---- legacy/3195 minimumArea/C#/MinimumArea.csproj | 10 -- legacy/3195 minimumArea/C#/Program.cs | 28 ----- legacy/3195 minimumArea/Go/main.go | 40 ------ legacy/326 isPowerOfThree/C#/Program.cs | 21 ---- .../C#/isPowerOfThree.csproj | 10 -- legacy/326 isPowerOfThree/description.md | 22 ---- legacy/326 isPowerOfThree/go/app.go | 26 ---- .../C#/MaxCollectedFruits.csproj | 10 -- .../C#/MaxCollectedFruits.sln | 24 ---- legacy/3363 MaxCollectedFruits/C#/Program.cs | 67 ---------- legacy/3446 SortMatrix/C#/C#.sln | 24 ---- legacy/3446 SortMatrix/C#/Program.cs | 115 ------------------ legacy/3446 SortMatrix/C#/SortMatrix.csproj | 10 -- legacy/498 FindDiagonalOrder/C#/C#.sln | 24 ---- .../C#/FindDiagonalOrder.csproj | 10 -- legacy/498 FindDiagonalOrder/C#/Program.cs | 61 ---------- legacy/498 FindDiagonalOrder/Go/main.go | 45 ------- legacy/498 FindDiagonalOrder/solution.md | 7 -- legacy/808 soupServings/C#/C#.sln | 24 ---- legacy/808 soupServings/C#/Program.cs | 56 --------- .../808 soupServings/C#/soupServings.csproj | 10 -- legacy/808 soupServings/Go/main.go | 52 -------- legacy/808 soupServings/description.md | 14 --- 38 files changed, 1119 deletions(-) delete mode 100755 legacy/2264 largestGoodInteger/C#/C#.sln delete mode 100755 legacy/2264 largestGoodInteger/C#/Program.cs delete mode 100755 legacy/2264 largestGoodInteger/C#/largestGoodInteger.csproj delete mode 100755 legacy/2264 largestGoodInteger/GO/main.go delete mode 100755 legacy/2438 ProductQueries/C#/2438 ProductQueries.sln delete mode 100755 legacy/2438 ProductQueries/C#/ProductQueries.csproj delete mode 100755 legacy/2438 ProductQueries/C#/Program.cs delete mode 100755 legacy/2438 ProductQueries/description.md delete mode 100755 legacy/2787 numberOfWays/C#/C#.sln delete mode 100755 legacy/2787 numberOfWays/C#/Program.cs delete mode 100755 legacy/2787 numberOfWays/C#/numberOfWays.csproj delete mode 100755 legacy/3000 areaOfMaxDiagonal/C#/Program.cs delete mode 100755 legacy/3000 areaOfMaxDiagonal/C#/areaOfMaxDiagonal.csproj delete mode 100755 legacy/3000 areaOfMaxDiagonal/GO/main.go delete mode 100755 legacy/3195 minimumArea/C#/C#.sln delete mode 100755 legacy/3195 minimumArea/C#/MinimumArea.csproj delete mode 100755 legacy/3195 minimumArea/C#/Program.cs delete mode 100755 legacy/3195 minimumArea/Go/main.go delete mode 100755 legacy/326 isPowerOfThree/C#/Program.cs delete mode 100755 legacy/326 isPowerOfThree/C#/isPowerOfThree.csproj delete mode 100755 legacy/326 isPowerOfThree/description.md delete mode 100755 legacy/326 isPowerOfThree/go/app.go delete mode 100755 legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.csproj delete mode 100755 legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.sln delete mode 100755 legacy/3363 MaxCollectedFruits/C#/Program.cs delete mode 100755 legacy/3446 SortMatrix/C#/C#.sln delete mode 100755 legacy/3446 SortMatrix/C#/Program.cs delete mode 100755 legacy/3446 SortMatrix/C#/SortMatrix.csproj delete mode 100755 legacy/498 FindDiagonalOrder/C#/C#.sln delete mode 100755 legacy/498 FindDiagonalOrder/C#/FindDiagonalOrder.csproj delete mode 100755 legacy/498 FindDiagonalOrder/C#/Program.cs delete mode 100755 legacy/498 FindDiagonalOrder/Go/main.go delete mode 100755 legacy/498 FindDiagonalOrder/solution.md delete mode 100755 legacy/808 soupServings/C#/C#.sln delete mode 100755 legacy/808 soupServings/C#/Program.cs delete mode 100755 legacy/808 soupServings/C#/soupServings.csproj delete mode 100755 legacy/808 soupServings/Go/main.go delete mode 100755 legacy/808 soupServings/description.md diff --git a/legacy/2264 largestGoodInteger/C#/C#.sln b/legacy/2264 largestGoodInteger/C#/C#.sln deleted file mode 100755 index 8e77df2..0000000 --- a/legacy/2264 largestGoodInteger/C#/C#.sln +++ /dev/null @@ -1,24 +0,0 @@ -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/legacy/2264 largestGoodInteger/C#/Program.cs b/legacy/2264 largestGoodInteger/C#/Program.cs deleted file mode 100755 index 3e0853f..0000000 --- a/legacy/2264 largestGoodInteger/C#/Program.cs +++ /dev/null @@ -1,63 +0,0 @@ -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/legacy/2264 largestGoodInteger/C#/largestGoodInteger.csproj b/legacy/2264 largestGoodInteger/C#/largestGoodInteger.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/2264 largestGoodInteger/C#/largestGoodInteger.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/2264 largestGoodInteger/GO/main.go b/legacy/2264 largestGoodInteger/GO/main.go deleted file mode 100755 index f5dc4a7..0000000 --- a/legacy/2264 largestGoodInteger/GO/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import "fmt" - -func LargestGoodInteger(num string) string { - max := "" - - for i := 0; i < len(num)-2; i++ { - if num[i] == num[i+1] && num[i] == num[i+2] { - current := string([]byte{num[i], num[i], num[i]}) - - if current > max { - max = current - } - } - } - - return max -} - -func main() { - fmt.Println(LargestGoodInteger("7636669283")) -} diff --git a/legacy/2438 ProductQueries/C#/2438 ProductQueries.sln b/legacy/2438 ProductQueries/C#/2438 ProductQueries.sln deleted file mode 100755 index 4edb15a..0000000 --- a/legacy/2438 ProductQueries/C#/2438 ProductQueries.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "ProductQueries", "C#\ProductQueries.csproj", "{412F89C4-B1BF-D819-298B-9C873A098742}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {412F89C4-B1BF-D819-298B-9C873A098742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {412F89C4-B1BF-D819-298B-9C873A098742}.Debug|Any CPU.Build.0 = Debug|Any CPU - {412F89C4-B1BF-D819-298B-9C873A098742}.Release|Any CPU.ActiveCfg = Release|Any CPU - {412F89C4-B1BF-D819-298B-9C873A098742}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BDF3A5A3-29B8-4169-8A46-A13A7DE900D8} - EndGlobalSection -EndGlobal diff --git a/legacy/2438 ProductQueries/C#/ProductQueries.csproj b/legacy/2438 ProductQueries/C#/ProductQueries.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/2438 ProductQueries/C#/ProductQueries.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/2438 ProductQueries/C#/Program.cs b/legacy/2438 ProductQueries/C#/Program.cs deleted file mode 100755 index 686d918..0000000 --- a/legacy/2438 ProductQueries/C#/Program.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; - -public class Solution -{ - public int[] ProductQueries(int n, int[][] queries) - { - // 1. n => calculate in powers of 2 - // 2. get number array without 0 - var powers = CalPower(n); - - return CalQueries(powers, queries); - - } - - private int[] CalPower(int n) - { - var result = new List(); - - while (n > 0) - { - var num = n % 2; - result.Add(num); - n /= 2; - } - - var newResult = new List(); - for (var i = 0; i < result.Count; i++) - { - if (result[i] != 0) - { - var ans = (int)Math.Pow(2, i); - newResult.Add(ans); - } - } - return newResult.ToArray(); - } - - private int[] CalQueries(int[] powers, int[][] queries) - { - const int MOD = 1000000007; - var result = new List(); - - foreach (var query in queries) - { - long count = 1; - for (var i = query[0]; i <= query[1]; i++) - { - count = (count * powers[i]) % MOD; - } - result.Add(count); - } - - return result.ToArray(); - } -} - -class Program -{ - static void Main() - { - var Solution = new Solution(); - - var ans = Solution.ProductQueries(15, [[0, 1], [2, 2], [0, 3]]); - Console.WriteLine(string.Join(", ", ans)); - - ans = Solution.ProductQueries(919, [[5,5],[4,4],[0,1],[1,5],[4,6],[6,6],[5,6],[0,3],[5,5],[5,6],[1,2],[3,5],[3,6],[5,5],[4,4],[1,1],[2,4],[4,5],[4,4],[5,6],[0,4],[3,3],[0,4],[0,5],[4,4],[5,5],[4,6],[4,5],[0,4],[6,6],[6,6],[6,6],[2,2],[0,5],[1,4],[0,3],[2,4],[5,5],[6,6],[2,2],[2,3],[5,5],[0,6],[3,3],[6,6],[4,4],[0,0],[0,2],[6,6],[6,6],[3,6],[0,4],[6,6],[2,2],[4,6]]); - Console.WriteLine(string.Join(", ", ans)); - } -} \ No newline at end of file diff --git a/legacy/2438 ProductQueries/description.md b/legacy/2438 ProductQueries/description.md deleted file mode 100755 index 3a44f57..0000000 --- a/legacy/2438 ProductQueries/description.md +++ /dev/null @@ -1,5 +0,0 @@ -Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n. The array is sorted in non-decreasing order, and there is only one way to form the array. - -You are also given a 0-indexed 2D integer array queries, where queries[i] = [lefti, righti]. Each queries[i] represents a query where you have to find the product of all powers[j] with lefti <= j <= righti. - -Return an array answers, equal in length to queries, where answers[i] is the answer to the ith query. Since the answer to the ith query may be too large, each answers[i] should be returned modulo 109 + 7. \ No newline at end of file diff --git a/legacy/2787 numberOfWays/C#/C#.sln b/legacy/2787 numberOfWays/C#/C#.sln deleted file mode 100755 index 7fd954e..0000000 --- a/legacy/2787 numberOfWays/C#/C#.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "numberOfWays", "numberOfWays.csproj", "{1E81E272-AF2C-9CB4-F90B-0AAC263D10DC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1E81E272-AF2C-9CB4-F90B-0AAC263D10DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E81E272-AF2C-9CB4-F90B-0AAC263D10DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E81E272-AF2C-9CB4-F90B-0AAC263D10DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E81E272-AF2C-9CB4-F90B-0AAC263D10DC}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AD18FC84-E2FB-4382-96DF-8AE7E50C1401} - EndGlobalSection -EndGlobal diff --git a/legacy/2787 numberOfWays/C#/Program.cs b/legacy/2787 numberOfWays/C#/Program.cs deleted file mode 100755 index 9f51042..0000000 --- a/legacy/2787 numberOfWays/C#/Program.cs +++ /dev/null @@ -1,48 +0,0 @@ -// knapsack problem -public class Solution -{ - public int NumberOfWays(int n, int x) - { - const int MOD = 1_000_000_007; - // list all the powers which smaller than n - var powers = new List(); - var num = 1; - - while (true) - { - int pow = (int)Math.Pow(num, x); - if (pow > n) - break; - powers.Add(pow); - num++; - } - - // dynamic programming - var dp = new int[n + 1]; - dp[0] = 1; - - foreach (var power in powers) - { - for (var i = n; i >= power; i--) - { - dp[i] = (dp[i] + dp[i - power]) % MOD; - } - } - - return dp[n]; - - } - -} - -class Program -{ - static void Main() - { - var solution = new Solution(); - - Console.WriteLine(solution.NumberOfWays(4, 1)); - Console.WriteLine(solution.NumberOfWays(100, 3)); - - } -} \ No newline at end of file diff --git a/legacy/2787 numberOfWays/C#/numberOfWays.csproj b/legacy/2787 numberOfWays/C#/numberOfWays.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/2787 numberOfWays/C#/numberOfWays.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/3000 areaOfMaxDiagonal/C#/Program.cs b/legacy/3000 areaOfMaxDiagonal/C#/Program.cs deleted file mode 100755 index ce53784..0000000 --- a/legacy/3000 areaOfMaxDiagonal/C#/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -public class Solution -{ - public int AreaOfMaxDiagonal(int[][] dimensions) - { - int max = 0; - int maxArea = 0; - - foreach (var dimension in dimensions) - { - var dimensionSqrt = dimension[0] * dimension[0] + dimension[1] * dimension[1]; - var area = dimension[0] * dimension[1]; - if (dimensionSqrt > max) - { - max = dimensionSqrt; - maxArea = area; - } - else if (dimensionSqrt == max) - { - maxArea = Math.Max(maxArea, area); - } - } - return maxArea; - } -} - -public class Program -{ - public static void Main() - { - var Solution = new Solution(); - - var dimensions = new int[][] { [6,5],[8,6],[2,10],[8,1],[9,2],[3,5],[3,5]}; - - var result = Solution.AreaOfMaxDiagonal(dimensions); - Console.WriteLine(result); - } -} - diff --git a/legacy/3000 areaOfMaxDiagonal/C#/areaOfMaxDiagonal.csproj b/legacy/3000 areaOfMaxDiagonal/C#/areaOfMaxDiagonal.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/3000 areaOfMaxDiagonal/C#/areaOfMaxDiagonal.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/3000 areaOfMaxDiagonal/GO/main.go b/legacy/3000 areaOfMaxDiagonal/GO/main.go deleted file mode 100755 index cf28307..0000000 --- a/legacy/3000 areaOfMaxDiagonal/GO/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - "math" -) - -func areaOfMaxDiagonal(dimensions [][]int) int{ - maxDiagonal := 0 - maxArea := 0 - - for _, dimension := range dimensions{ - l := dimension[0] - w := dimension[1] - diagonalSquare := l * l + w * w - area := l * w - - if diagonalSquare > maxDiagonal{ - maxDiagonal = diagonalSquare - maxArea = area - }else if diagonalSquare == maxDiagonal{ - maxArea = int(math.Max(float64(maxArea), float64(area))) - } - } - - return maxArea -} \ No newline at end of file diff --git a/legacy/3195 minimumArea/C#/C#.sln b/legacy/3195 minimumArea/C#/C#.sln deleted file mode 100755 index ab76e74..0000000 --- a/legacy/3195 minimumArea/C#/C#.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "MinimumArea", "MinimumArea.csproj", "{61A8B87F-638B-4246-13C4-CC226CFBBEA5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {61A8B87F-638B-4246-13C4-CC226CFBBEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {61A8B87F-638B-4246-13C4-CC226CFBBEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {61A8B87F-638B-4246-13C4-CC226CFBBEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {61A8B87F-638B-4246-13C4-CC226CFBBEA5}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C6FDF6F7-60CD-4B35-B619-6F79B7243CA7} - EndGlobalSection -EndGlobal diff --git a/legacy/3195 minimumArea/C#/MinimumArea.csproj b/legacy/3195 minimumArea/C#/MinimumArea.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/3195 minimumArea/C#/MinimumArea.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/3195 minimumArea/C#/Program.cs b/legacy/3195 minimumArea/C#/Program.cs deleted file mode 100755 index 24fd372..0000000 --- a/legacy/3195 minimumArea/C#/Program.cs +++ /dev/null @@ -1,28 +0,0 @@ -public class Solution { - public int MinimumArea(int[][] grid) - { - var x = grid[0].Length; - var y = grid.Length; - - int min_x = x; - int max_x = 0; - int min_y = y; - int max_y = 0; - - for (var i = 0; i < x; i++) - { - for (var j = 0; j < y; j++) - { - if (grid[j][i]) - { - min_x = Math.Min(min_x, i); - max_x = Math.Max(max_x, i); - min_y = Math.Min(min_y, j); - max_y = Math.Max(max_y, j); - } - } - } - - return (max_x - min_x + 1) * (max_y - min_y + 1); - } -} \ No newline at end of file diff --git a/legacy/3195 minimumArea/Go/main.go b/legacy/3195 minimumArea/Go/main.go deleted file mode 100755 index ae10def..0000000 --- a/legacy/3195 minimumArea/Go/main.go +++ /dev/null @@ -1,40 +0,0 @@ -package main - -import "fmt" - -func minimumArea(grid [][]int) int { - row := len(grid) - col := len(grid[0]) - - min_x := col - max_x := 0 - min_y := row - max_y := 0 - - for i:=0; i b{ - return a - } - return b -} \ No newline at end of file diff --git a/legacy/326 isPowerOfThree/C#/Program.cs b/legacy/326 isPowerOfThree/C#/Program.cs deleted file mode 100755 index a522990..0000000 --- a/legacy/326 isPowerOfThree/C#/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -public class Solution { - public bool IsPowerOfThree(int n) { - if(n <= 0) - return false; - if(n == 1) - return true; - if(n % 3 != 0) - return false; - return IsPowerOfThree(n/3); - } -} - -class program{ - static void Main(){ - var Solution = new Solution(); - - Console.WriteLine(Solution.IsPowerOfThree(9)); - Console.WriteLine(Solution.IsPowerOfThree(0)); - Console.WriteLine(Solution.IsPowerOfThree(-1)); - } -} \ No newline at end of file diff --git a/legacy/326 isPowerOfThree/C#/isPowerOfThree.csproj b/legacy/326 isPowerOfThree/C#/isPowerOfThree.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/326 isPowerOfThree/C#/isPowerOfThree.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/326 isPowerOfThree/description.md b/legacy/326 isPowerOfThree/description.md deleted file mode 100755 index d4e511c..0000000 --- a/legacy/326 isPowerOfThree/description.md +++ /dev/null @@ -1,22 +0,0 @@ -Given an integer n, return true if it is a power of three. Otherwise, return false. - -An integer n is a power of three, if there exists an integer x such that n == 3x. - - - -Example 1: - -Input: n = 27 -Output: true -Explanation: 27 = 33 -Example 2: - -Input: n = 0 -Output: false -Explanation: There is no x where 3x = 0. -Example 3: - -Input: n = -1 -Output: false -Explanation: There is no x where 3x = (-1). - \ No newline at end of file diff --git a/legacy/326 isPowerOfThree/go/app.go b/legacy/326 isPowerOfThree/go/app.go deleted file mode 100755 index c3b67ae..0000000 --- a/legacy/326 isPowerOfThree/go/app.go +++ /dev/null @@ -1,26 +0,0 @@ -package main - -import "fmt" - -type Solution struct{} - -func (s Solution) IsPowerOfThree(n int) bool{ - if n <= 0{ - return false - } - if n == 1{ - return true - } - if n % 3 != 0{ - return false - } - return s.IsPowerOfThree(n/3) -} - -func main(){ - solution := Solution{} - - fmt.Println(solution.IsPowerOfThree(27)) - fmt.Println(solution.IsPowerOfThree(0)) - fmt.Println(solution.IsPowerOfThree(-1)) -} \ No newline at end of file diff --git a/legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.csproj b/legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.sln b/legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.sln deleted file mode 100755 index e5f8bd0..0000000 --- a/legacy/3363 MaxCollectedFruits/C#/MaxCollectedFruits.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "MaxCollectedFruits", "MaxCollectedFruits.csproj", "{AA67CF61-67B3-7229-E3F9-D471B0EF4EDE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AA67CF61-67B3-7229-E3F9-D471B0EF4EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AA67CF61-67B3-7229-E3F9-D471B0EF4EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AA67CF61-67B3-7229-E3F9-D471B0EF4EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AA67CF61-67B3-7229-E3F9-D471B0EF4EDE}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B9D47F51-61C3-4A24-890A-01C9AC85EC93} - EndGlobalSection -EndGlobal diff --git a/legacy/3363 MaxCollectedFruits/C#/Program.cs b/legacy/3363 MaxCollectedFruits/C#/Program.cs deleted file mode 100755 index 3824bef..0000000 --- a/legacy/3363 MaxCollectedFruits/C#/Program.cs +++ /dev/null @@ -1,67 +0,0 @@ -public class Solution -{ - public int MaxCollectedFruits(int[][] fruits) - { - int n = fruits.Length; - int ans = 0; - for (int i = 0; i < n; ++i) ans += fruits[i][i]; - - int dp() - { - int[] prev = Enumerable.Repeat(int.MinValue, n).ToArray(); - int[] curr = new int[n]; - prev[n - 1] = fruits[0][n - 1]; - for (int i = 1; i < n - 1; ++i) - { - Array.Fill(curr, int.MinValue); - for (int j = Math.Max(n - 1 - i, i + 1); j < n; ++j) - { - int best = prev[j]; - if (j - 1 >= 0) - { - best = Math.Max(best, prev[j - 1]); - } - if (j + 1 < n) - { - best = Math.Max(best, prev[j + 1]); - } - curr[j] = best + fruits[i][j]; - } - var temp = prev; - prev = curr; - curr = temp; - } - return prev[n - 1]; - } - - ans += dp(); - - for (int i = 0; i < n; ++i) - { - for (int j = 0; j < i; ++j) - { - var temp = fruits[j][i]; - fruits[j][i] = fruits[i][j]; - fruits[i][j] = temp; - } - } - - ans += dp(); - return ans; - } - - -} - - -class Program -{ - static void Main() - { - var Solution = new Solution(); - - var fruits = new int[][] { [1,2,3,4],[5,6,8,7],[9,10,11,12],[13,14,15,16]}; - - Console.WriteLine(Solution.MaxCollectedFruits(fruits)); - } -} \ No newline at end of file diff --git a/legacy/3446 SortMatrix/C#/C#.sln b/legacy/3446 SortMatrix/C#/C#.sln deleted file mode 100755 index 6170ac3..0000000 --- a/legacy/3446 SortMatrix/C#/C#.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "SortMatrix", "SortMatrix.csproj", "{60318F94-4F41-A4B8-C189-A8135ECCECCB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {60318F94-4F41-A4B8-C189-A8135ECCECCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {60318F94-4F41-A4B8-C189-A8135ECCECCB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {60318F94-4F41-A4B8-C189-A8135ECCECCB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {60318F94-4F41-A4B8-C189-A8135ECCECCB}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9F59D1F6-D9F3-492C-BC39-A5771AF22B36} - EndGlobalSection -EndGlobal diff --git a/legacy/3446 SortMatrix/C#/Program.cs b/legacy/3446 SortMatrix/C#/Program.cs deleted file mode 100755 index 88ecb10..0000000 --- a/legacy/3446 SortMatrix/C#/Program.cs +++ /dev/null @@ -1,115 +0,0 @@ -public class Solution -{ - public int[][] SortMatrix(int[][] grid) - { - // 左下 - var leftDiagonals = new Dictionary>(); - for (var i = 0; i < grid.Length; i++) - { - // total -> 2n + 1 way - for (var j = 0; j <= i; j++) - { - int diagonal = i - j; - if (!leftDiagonals.ContainsKey(diagonal)) - { - leftDiagonals[diagonal] = new List(); - } - leftDiagonals[diagonal].Add(grid[i][j]); - } - } - - // 右上 - var rightDiagonals = new Dictionary>(); - for (var i = 0; i < grid.Length; i++) - { - for (var j = i; j < grid.Length; j++) - { - int diagonal = j - i; - if (!rightDiagonals.ContainsKey(diagonal)) - { - rightDiagonals[diagonal] = new List(); - } - rightDiagonals[diagonal].Add(grid[i][j]); - } - } - - foreach (var diagonal in leftDiagonals.Values) - { - diagonal.Sort((a, b) => b.CompareTo(a)); - } - - foreach (var diagonal in rightDiagonals.Values) - { - diagonal.Sort((a, b) => a.CompareTo(b)); - } - - for (var i = 0; i < grid.Length; i++) - { - for (var j = 0; j <= i; j++) - { - int diagonal = i - j; - grid[i][j] = leftDiagonals[diagonal][0]; - leftDiagonals[diagonal].RemoveAt(0); - } - - for (var j = i; j < grid.Length; j++) - { - if (i == j) continue; - int diagonal = j - i; - grid[i][j] = rightDiagonals[diagonal][0]; - rightDiagonals[diagonal].RemoveAt(0); - } - } - return grid; - } -} - -public class Solution2 { - public int[][] SortMatrix(int[][] grid) { - int n = grid.Length; - - for (int i = 0; i < n; i++) { - List tmp = new List(); - for (int j = 0; i + j < n; j++) { - tmp.Add(grid[i + j][j]); - } - tmp.Sort((a, b) => b.CompareTo(a)); - for (int j = 0; i + j < n; j++) { - grid[i + j][j] = tmp[j]; - } - } - - for (int j = 1; j < n; j++) { - List tmp = new List(); - for (int i = 0; j + i < n; i++) { - tmp.Add(grid[i][j + i]); - } - tmp.Sort(); - for (int i = 0; j + i < n; i++) { - grid[i][j + i] = tmp[i]; - } - } - - return grid; - } -} - -class Program -{ - static void Main() - { - var Solution = new Solution(); - - var gird = new int[][] { [1, 7, 3], [9, 8, 2], [4, 5, 6] }; - var result = Solution.SortMatrix(gird); - - for (int i = 0; i < result.Length; i++) - { - for (int j = 0; j < result[i].Length; j++) - { - Console.Write(result[i][j] + " "); - } - Console.WriteLine(); - } - } -} \ No newline at end of file diff --git a/legacy/3446 SortMatrix/C#/SortMatrix.csproj b/legacy/3446 SortMatrix/C#/SortMatrix.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/3446 SortMatrix/C#/SortMatrix.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/498 FindDiagonalOrder/C#/C#.sln b/legacy/498 FindDiagonalOrder/C#/C#.sln deleted file mode 100755 index cd97c96..0000000 --- a/legacy/498 FindDiagonalOrder/C#/C#.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "FindDiagonalOrder", "FindDiagonalOrder.csproj", "{B3151728-C057-4305-DD4C-9A2AFBFC189A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3151728-C057-4305-DD4C-9A2AFBFC189A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3151728-C057-4305-DD4C-9A2AFBFC189A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3151728-C057-4305-DD4C-9A2AFBFC189A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3151728-C057-4305-DD4C-9A2AFBFC189A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {DB56539A-6F32-4D28-B91F-BB1DCF46F4D0} - EndGlobalSection -EndGlobal diff --git a/legacy/498 FindDiagonalOrder/C#/FindDiagonalOrder.csproj b/legacy/498 FindDiagonalOrder/C#/FindDiagonalOrder.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/498 FindDiagonalOrder/C#/FindDiagonalOrder.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/498 FindDiagonalOrder/C#/Program.cs b/legacy/498 FindDiagonalOrder/C#/Program.cs deleted file mode 100755 index e1f13ce..0000000 --- a/legacy/498 FindDiagonalOrder/C#/Program.cs +++ /dev/null @@ -1,61 +0,0 @@ -public class Solution { - public int[] FindDiagonalOrder(int[][] mat) - { - if (mat == null || mat.Length == 0 || mat[0].Length == 0) - { - return new int[0]; - } - - var m = mat.Length; - var n = mat[0].Length; - - var diagonals = new Dictionary>(); - - for (var i = 0; i < m; i++) - { - for (var j = 0; j < n; j++) - { - int diagonalIndex = i + j; - if (!diagonals.ContainsKey(diagonalIndex)) - { - diagonals[diagonalIndex] = new List(); - } - diagonals[diagonalIndex].Add(mat[i][j]); - } - } - - var result = new List(); - foreach (var key in diagonals.Keys) - { - var diagonal = diagonals[key]; - if (key % 2 == 0) - { - result.AddRange(diagonal); - } - else - { - diagonal.Reverse(); - result.AddRange(diagonal); - } - } - - return result.ToArray(); - } -} - -class Program -{ - static void Main() - { - var Solution = new Solution(); - - int[][] mat1 = new int[][]{ - new int[]{1,2,3}, - new int[]{4,5,6}, - new int[]{7,8,9} - }; - - Console.WriteLine(string.Join(", ", Solution.FindDiagonalOrder(mat1))); - - } -} \ No newline at end of file diff --git a/legacy/498 FindDiagonalOrder/Go/main.go b/legacy/498 FindDiagonalOrder/Go/main.go deleted file mode 100755 index f3fe8dc..0000000 --- a/legacy/498 FindDiagonalOrder/Go/main.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import "fmt" - -func findDiagonalOrder(mat [][]int) []int { - if len(mat) == 0 || len(mat[0]) == 0{ - return []int{} - } - - m := len(mat) - n := len(mat[0]) - - // maps - diagonals := make(map[int][]int) - - for i:=0; i< m;i++{ - for j:=0; j < n; j++{ - index := i+j - diagonals[index] = append(diagonals[index], mat[i][j]) - } - } - - result := []int{} - - for i:= 0; i< m+n-1; i++{ - if i% 2 == 0{ - reverse(diagonals[i]) - result = append(result, diagonals[i]...) - }else{ - result = append(result, diagonals[i]...) - } - } - - return result -} - -func reverse(slice []int){ - left, right :=0, len(slice)-1 - - for left < right{ - slice[left], slice[right] = slice[right], slice[left] - left++ - right-- - } -} \ No newline at end of file diff --git a/legacy/498 FindDiagonalOrder/solution.md b/legacy/498 FindDiagonalOrder/solution.md deleted file mode 100755 index b855319..0000000 --- a/legacy/498 FindDiagonalOrder/solution.md +++ /dev/null @@ -1,7 +0,0 @@ -1. 觀察矩陣對角線模式 - 1. (0,0) -> 1 -> i+j = 0 - 2. (1, 0), (0, 1) -> 2 -> i+j = 1 - 3. (2, 0), (1, 1), (0, 2) -> 3 -> i+j = 2 -2. how to deal with diagonal sorting? - 1. while (i+j) % 2 == 1 - 2. while (i+j) % 2 == 0 reversed \ No newline at end of file diff --git a/legacy/808 soupServings/C#/C#.sln b/legacy/808 soupServings/C#/C#.sln deleted file mode 100755 index b703431..0000000 --- a/legacy/808 soupServings/C#/C#.sln +++ /dev/null @@ -1,24 +0,0 @@ -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}") = "soupServings", "soupServings.csproj", "{6D960F00-6A53-6E19-86A1-4BF3D1CD764F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6D960F00-6A53-6E19-86A1-4BF3D1CD764F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D960F00-6A53-6E19-86A1-4BF3D1CD764F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D960F00-6A53-6E19-86A1-4BF3D1CD764F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6D960F00-6A53-6E19-86A1-4BF3D1CD764F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {11CC27B7-C17E-4820-8A68-ADD32A2B37F8} - EndGlobalSection -EndGlobal diff --git a/legacy/808 soupServings/C#/Program.cs b/legacy/808 soupServings/C#/Program.cs deleted file mode 100755 index 0086f36..0000000 --- a/legacy/808 soupServings/C#/Program.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; - -public class Solution -{ - private Dictionary<(int, int), double> dp = new Dictionary<(int, int), double>(); - public double SoupServings(int n) - { - if (n > 5000) - return 1.0; - - n = (n + 24) / 25; - - // use dynamic programming - return Helper(n, n); - } - - private double Helper(int a, int b) - { - if (a <= 0 && b <= 0) - { - return 0.5; - } - if (a <= 0) - { - return 1.0; - } - if (b <= 0) - { - return 0.0; - } - if (dp.ContainsKey((a, b))) - { - return dp[(a, b)]; - } - - double probability = 0.25 * ( - Helper(a - 4, b) + - Helper(a - 3, b - 1) + - Helper(a - 2, b - 2) + - Helper(a - 1, b - 3) - ); - - dp[(a, b)] = probability; - return probability; - } -} - -class Program -{ - static void Main() - { - var Solution = new Solution(); - var ans = Solution.SoupServings(800); - Console.WriteLine(ans); - } -} \ No newline at end of file diff --git a/legacy/808 soupServings/C#/soupServings.csproj b/legacy/808 soupServings/C#/soupServings.csproj deleted file mode 100755 index 2150e37..0000000 --- a/legacy/808 soupServings/C#/soupServings.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - - diff --git a/legacy/808 soupServings/Go/main.go b/legacy/808 soupServings/Go/main.go deleted file mode 100755 index e598017..0000000 --- a/legacy/808 soupServings/Go/main.go +++ /dev/null @@ -1,52 +0,0 @@ -package main - -import ("fmt") - -type Solution struct{ - dp map[[2]int]float64 -} - -func NewSolution() *Solution{ - return &Solution{dp: make(map[[2]int]float64)} -} - -func (s *Solution) SoupServings(n int)float64{ - if n > 5000{ - return 1.0 - } - - n = (n+24) /25 - - return s.helper(n, n) -} - -func (s * Solution) helper(a, b int) float64 { - if a <= 0 && b <= 0{ - return 0.5 - } - if a <= 0{ - return 1.0 - } - if b <= 0{ - return 0 - } - - if val, exist := s.dp[[2]int{a, b}]; exist{ - return val - } - - probability := 0.25 * ( - s.helper(a-4, b) + - s.helper(a-3, b-1) + - s.helper(a-2, b-2) + - s.helper(a-1, b-3)) - - s.dp[[2]int {a, b}] = probability - return probability -} - -func main(){ - Solution := NewSolution() - ans := Solution.SoupServings(100) - fmt.Println(ans) -} \ No newline at end of file diff --git a/legacy/808 soupServings/description.md b/legacy/808 soupServings/description.md deleted file mode 100755 index b780424..0000000 --- a/legacy/808 soupServings/description.md +++ /dev/null @@ -1,14 +0,0 @@ -You have two soups, A and B, each starting with n mL. On every turn, one of the following four serving operations is chosen at random, each with probability 0.25 independent of all previous turns: - -pour 100 mL from type A and 0 mL from type B -pour 75 mL from type A and 25 mL from type B -pour 50 mL from type A and 50 mL from type B -pour 25 mL from type A and 75 mL from type B -Note: - -There is no operation that pours 0 mL from A and 100 mL from B. -The amounts from A and B are poured simultaneously during the turn. -If an operation asks you to pour more than you have left of a soup, pour all that remains of that soup. -The process stops immediately after any turn in which one of the soups is used up. - -Return the probability that A is used up before B, plus half the probability that both soups are used up in the same turn. Answers within 10-5 of the actual answer will be accepted. \ No newline at end of file