# Find three elements in an array that sum to a zero.

**Objective**: Given an array of integer write an algorithm to find 3 elements that sum to a zero. In short a+b+c = 0.

**Example**

inta [] = { 3,-1,-7,-4,-5,9,10}; Elements are -4 9 -5

**Approach: Brute Force**

Use 3 nested loops and find the 3 elements which sum to 0.

Time Complexity: O(n^3)

**Code:**

**Approach: Sorting**

- Sort the array.
- Use the other loop to fix the one element at a time, say its ‘a’.
- Now problem is reduced to “Find a pair of numbers from an array whose sum equals -a”Time Complexity: O(n^2)
**Code:**