The following code is running okay for the input set [1,4], [1,4] in visual studio 2012 editor and gives the expected result [1,4]. But while submitting the code in Leetcode its throwing run time error. Any help is appreciated.

public class Solution

{

public IList<Interval> Execute(IList<Interval> intervals)

{

```
for (int i = 0; i < intervals.Count; i++)
{
if (i == 0)
{
continue;
}
if (intervals[i - 1].end > intervals[i].start)
{
intervals[i - 1].end = intervals[i].end;
Interval objInterval = new Interval();
objInterval = intervals[i];
intervals.Remove(objInterval);
}
}
return intervals;
}
}
public class Interval
{
public int start;
public int end;
public Interval() { start = 0; end = 0; }
public Interval(int s, int e) { start = s; end = e; }
}
```