Simple Binary Search based Solution - O(nlogn)
csharp\npublic class Solution {\n  public int LastStoneWeight(int[] stones)\n        {\n            if (stones.Length == 2)\n            {\n                retu
``` csharp\npublic class Solution {\n  public int LastStoneWeight(int[] stones)\n        {\n            if (stones.Length == 2)\n            {\n                return Math.Abs(stones[1] - stones[0]);\n            }\n\n            Array.Sort(stones);\n            List<int> s = new List<int>(stones);\n\n            while (s.Count > 1)\n            {\n                int first = s.ElementAt(s.Count - 1);\n                int second = s.ElementAt(s.Count - 2);\n                int smash = first - second;\n                s.RemoveAt(s.Count - 1);\n                s.RemoveAt(s.Count - 1);\n\n                if (smash != 0)\n                {\n                    int index = s.BinarySearch(smash);\n                    if (index < 0)\n                    {\n                        index = ~index;\n                    }\n                    s.Insert(index, smash);\n                }\n            }\n\n            return s.FirstOrDefault();\n    }\n}\n```
['Binary Search']