Files
Leetcode/18. 4Sum/Program.cs
2026-03-25 16:58:20 +03:00

41 lines
1019 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
var sol = new Solution();
var cases = new (int[] nums, int target, int[][] expected)[]
{
// (new[] { 1, 0, -1, 0, -2, 2 }, 0, new[]
// {
// new[] { -2, -1, 1, 2 },
// new[] { -2, 0, 0, 2 },
// new[] { -1, 0, 0, 1 }
// }),
// (new[] { 2, 2, 2, 2, 2 }, 8, new[]
// {
// new[] { 2, 2, 2, 2 }
// }),
// (new[] { -3, -1, 0, 2, 4, 5 }, 2, new[]
// {
// new[] { -3, -1, 2, 4 }
// }),
(new[] { 1000000000, 1000000000, 1000000000, 1000000000 }, -294967296, Array.Empty<int[]>())
};
foreach (var (nums, target, expected) in cases)
{
var actual = sol.FourSum(nums, target);
Console.WriteLine($"nums={FormatArray(nums)}, target={target} -> {FormatResults(actual)} (expected: {FormatResults(expected)})");
}
static string FormatArray(int[] nums)
{
return $"[{string.Join(",", nums)}]";
}
static string FormatResults(IList<IList<int>> results)
{
return "[" + string.Join(",", results.Select(r => $"[{string.Join(",", r)}]")) + "]";
}