# Two Sum

C# Algorithmic thinking Searching Public

C#

The C# programming language is a simple, modern, general-purpose, object-oriented programming language. Having a basic familiarity with the programming language used on the job is a prerequisite for quickly getting up to speed.

Algorithmic thinking

When designing and/or analyzing an algorithm or data structure, it is important to consider the performance and structure of an implementation. Algorithmic thinking is one of the key traits of a good programmer, especially one working on complex or performance-critical code.

Searching

Every programmer should be familiar with data-searching methods, as they are very common in data-analysis processes.

Public

*Public questions*(free account) are common interview questions. They are great for practicing, or if you want to filter candidates using the classic problems.

Write a function that, when passed a list and a target sum, returns, **efficiently** with respect to time used, two distinct** **zero-based indices of any two of the numbers, whose sum is equal to the target sum. If there are no two numbers, the function should return *null*.

For example, *FindTwoSum(new List<int>() { 3, 1, 5, 7, 5, 9 }, 10)* should return a *Tuple<int, int>* containing any of the following pairs of indices:

- 0 and 3 (or 3 and 0) as 3 + 7 = 10
- 1 and 5 (or 5 and 1) as 1 + 9 = 10
- 2 and 4 (or 4 and 2) as 5 + 5 = 10

C# 7.0, .NET Framework 4.7

- Example case: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8
- Distinct numbers with and without solutions: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8
- Duplicate numbers with and without solutions: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8
- Performance test with a large list of numbers: System.NotImplementedException at TwoSum.FindTwoSum(IList`1 list, Int32 sum) in TwoSum.cs:line 8