Easy C# Solution With Explanation
1) Get Ranges of available numbers\n2) Choose weighted range randomly (see https://leetcode.com/problems/random-pick-with-weight/). Weight = size of range\n3) P
1) Get Ranges of available numbers\n2) Choose weighted range randomly (see https://leetcode.com/problems/random-pick-with-weight/). Weight = size of range\n3) Pick any number in choosen range\n\n```\n    public class Solution\n    {\n        private readonly IList<(int from, int to)> _ranges;\n        private readonly int[] _weightdRangesIndices;\n        private readonly Random _rnd;\n\n        public Solution(int n, int[] blacklist)\n        {\n            _rnd = new Random();\n            _ranges = new List<(int @from, int to)>();\n\n            Array.Sort(blacklist);\n\n            int from = 0;\n            int to = 0;\n\n            for (int i = 0; i < blacklist.Length; i++)\n            {\n                to = blacklist[i];\n\n                if (from < to)\n                {\n                    _ranges.Add((from, to));\n                }\n\n                from = to + 1;\n            }\n\n            to = n;\n\n            if (from < to)\n            {\n                _ranges.Add((from, to));\n            }\n\n            _weightdRangesIndices = new int[_ranges.Count];\n            int sumWeight = 0;\n            for (int i = 0; i < _ranges.Count; i++)\n            {\n                sumWeight += (_ranges[i].to - _ranges[i].from);\n                _weightdRangesIndices[i] = sumWeight;\n            }\n        }\n\n        //https://leetcode.com/problems/random-pick-with-weight/\n        private int PickRangeIndex()\n        {\n            int weight = _rnd.Next(0, _weightdRangesIndices.Last()) + 1;\n            int res = Array.BinarySearch(_weightdRangesIndices, weight);\n            return res >= 0 ? res : -res - 1;\n        }\n\n        public int Pick()\n        {\n            int rangeIdx = PickRangeIndex();\n            return _rnd.Next(_ranges[rangeIdx].from, _ranges[rangeIdx].to);\n        }\n    }\n```
[]