2508/3195 #1
24
202508/3195 minimumArea/C#/C#.sln
Executable file
24
202508/3195 minimumArea/C#/C#.sln
Executable file
@@ -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}") = "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
|
10
202508/3195 minimumArea/C#/MinimumArea.csproj
Executable file
10
202508/3195 minimumArea/C#/MinimumArea.csproj
Executable file
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
28
202508/3195 minimumArea/C#/Program.cs
Executable file
28
202508/3195 minimumArea/C#/Program.cs
Executable file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user