Coding problem
The log lines between START and END
The task
A deployment log marks the start and the end of a run with a line that says START and a line that says END. The build page shows the lines of the first run.
Complete FirstRun(List<LogLine> log). LogLine is a record with a line Number and its Text. Find the first line whose Text is exactly "START" and return the lines after it, up to but not including the next line whose Text is exactly "END". With no START line, return an empty list; when no END line follows the START line, return every line after START. Only a whole text of START or END counts as a marker. The list and its lines are never null.
Signature
public record LogLine(int Number, string Text); public static List<LogLine> FirstRun(List<LogLine> log)
Examples
[(1, "boot"), (2, "START"), (3, "copy files"), (4, "restart"), (5, "END"), (6, "cleanup")]→[(3, "copy files"), (4, "restart")]. These are the lines between START and END.[(1, "START"), (2, "copy files")]→[(2, "copy files")]. No END follows, so every line after START is kept.
Limits: Up to 500,000 lines.
The tests check: an empty log, no START, no END, START followed at once by END, only the first run kept, texts that only contain the words, an END before the START, and 500,000 lines in time.
Hints
The solution opens by itself when all tests pass. You remember more if you try first.
Sign in to see the solutionYour code
Already included: using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; using System.Threading; using System.Threading.Tasks;
public record LogLine(int Number, string Text);
public static class Solution
{
// The lines after the first START, up to (not including) the next END.
public static List<LogLine> FirstRun(List<LogLine> log)
{
throw new NotImplementedException();
}
}Sign in to run and submit your code. It stays here while you do.