TopCoder SRM596: FoxAndSightseeing
先頭と末尾以外の要素についてスキップを試す。
public class FoxAndSightseeing { public int getMin(int[] position) { int n = position.Length; var candidate = Enumerable.Range(1, n - 2) .Select(i => position.Where((v, index) => index != i)) .ToArray(); return candidate.Select(a => a.Zip(a.Skip(1), (a0, a1) => Math.Abs(a0 - a1)).Sum()).Min(); }