Initial commit
This commit is contained in:
11
1. Two Sum/1. Two Sum.csproj
Normal file
11
1. Two Sum/1. Two Sum.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>_1._Two_Sum</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
10
1. Two Sum/Program.cs
Normal file
10
1. Two Sum/Program.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace _1._Two_Sum
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
1. Two Sum/Solution.cs
Normal file
19
1. Two Sum/Solution.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace _1._Two_Sum;
|
||||
|
||||
public class Solution
|
||||
{
|
||||
public int[]? TwoSum(int[] nums, int target)
|
||||
{
|
||||
for (int i = 0; i < nums.Length; i++)
|
||||
for (int j = i+1; j < nums.Length; j++)
|
||||
if (nums[i] + nums[j] == target)
|
||||
return new int[] { i, j };
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user