Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions leetcode2/1easy/노형민/Q3633.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
public class Solution
{
public int EarliestFinishTime(int[] landStartTime, int[] landDuration, int[] waterStartTime, int[] waterDuration)
{
int minTime = 10000;
for (int i = 0; i < landStartTime.Length; i++)
{
for (int j = 0; j < waterStartTime.Length; j++)
{
int currentTime = landStartTime[i] + landDuration[i];
if (waterStartTime[j] <= currentTime)
{
currentTime += waterDuration[j];
}
else
{
currentTime = waterStartTime[j] + waterDuration[j];
}

if (currentTime < minTime)
{
minTime = currentTime;
}
}
}

for (int i = 0; i < waterStartTime.Length; i++)
{
for (int j = 0; j < landStartTime.Length; j++)
{
int currentTime = waterStartTime[i] + waterDuration[i];
if (landStartTime[j] <= currentTime)
{
currentTime += landDuration[j];
}
else
{
currentTime = landStartTime[j] + landDuration[j];
}

if (currentTime < minTime)
{
minTime = currentTime;
}
}
}

return minTime;
}
}
50 changes: 50 additions & 0 deletions leetcode2/2medium/노형민/Q808.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
public class Solution
{
double?[,] possibility;

public double SoupServings(int n)
{
n = (n+24) / 25;

if (n > 4800)
{
return 1.0;
}

possibility = new double?[n + 1, n + 1];

return GetPossibility(n, n);
}

private double GetPossibility(int i, int j)
{
if (i <= 0 && j <= 0)
{
return 0.5;
}
if (i <= 0)
{
return 1.0;
}
if (j <= 0)
{
return 0.0;
}

if (possibility[i, j] != null)
{
return possibility[i, j].Value;
}

double result = 0.25 * (
GetPossibility(i - 4, j) +
GetPossibility(i - 3, j - 1) +
GetPossibility(i - 2, j - 2) +
GetPossibility(i - 1, j - 3)
);

possibility[i, j] = result;

return result;
}
}