This commit is contained in:
2026-03-25 16:58:20 +03:00
parent d99b7d18e3
commit 2464aeff0e
4 changed files with 208 additions and 0 deletions

40
18. 4Sum/Program.cs Normal file
View File

@@ -0,0 +1,40 @@
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)}]")) + "]";
}