/*
- @Author: sumBorn
- @Date: 2022-02-23 22:50:47
- @LastEditTime: 2022-02-24 00:08:36
- @Description: https://leetcode-cn.com/leetbook/read/all-about-array/x9i1x6/
*/
/**
- @description: 暴力法,时间复杂度O2
- @param {*}
- @return {*}
*/
public class Solution
{
public int[] TwoSum(int[] numbers, int target)
{
for (var i = 0; i < numbers.Length; i++)
{
for (var j = i + 1; j < numbers.Length; j++)
{
if (numbers[i] + numbers[j] == target)
{
return new int[] { i + 1, j + 1 };
}
}
}
return new int[] { };
}
}
网友评论