Clear
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user