This commit is contained in:
Electrominch
2022-10-07 00:48:48 +03:00
parent 0b88604037
commit e711e64e07
18 changed files with 45 additions and 45 deletions

View File

@@ -4,7 +4,7 @@
{
static void Main(string[] args)
{
var arr = new int[] { -2,-3,4 };
var arr = new int[] { -2, -3, 4 };
var res = new Solution().TwoSum(arr, -5);
Console.WriteLine(String.Join(" ", res));
}

View File

@@ -4,7 +4,7 @@ public class Solution
{
public int[]? TwoSum(int[] numbers, int target)
{
for(int i = 0; i < numbers.Length; i++)
for (int i = 0; i < numbers.Length; i++)
{
int cur = numbers[i];
int nextTar = target - cur;
@@ -14,7 +14,7 @@ public class Solution
int val = numbers[index];
if (cur + val == target)
{
if(i>index)
if (i > index)
{
i = i + index;
index = i - index;