public static List <int> FindAllDuplicates(int[] nums)
        {
            int i = 0;

            while (i < nums.Length)
            {
                if (nums[i] != i + 1 && nums[i] != nums[nums[i] - 1])
                {
                    FindMissingNumber.Swap(i, nums[i] - 1, nums);
                }
                else
                {
                    i++;
                }
            }
            List <int> duplicateNumbers = new List <int>();

            for (i = 0; i < nums.Length; i++)
            {
                if (nums[i] != i + 1)
                {
                    duplicateNumbers.Add(nums[i]);
                }
            }

            return(duplicateNumbers);
        }
        public static List <int> FindAllNumbers(int[] nums)
        {
            List <int> missingNumbers = new();
            // TODO: Write your code here
            int i = 0;

            while (i < nums.Length)
            {
                if (nums[i] != i + 1 && nums[i] != nums[nums[i] - 1])
                {
                    FindMissingNumber.Swap(i, nums[i] - 1, nums);
                }
                else
                {
                    i++;
                }
            }

            for (i = 0; i < nums.Length; i++)
            {
                if (nums[i] != i + 1)
                {
                    missingNumbers.Add(i + 1);
                }
            }

            return(missingNumbers);
        }
        public static int Find(int[] nums)
        {
            // TODO: Write your code here

            int i = 0;

            while (i < nums.Length)
            {
                if (nums[i] != i + 1)
                {
                    if (nums[nums[i] - 1] != nums[i])
                    {
                        FindMissingNumber.Swap(i, nums[i] - 1, nums);
                    }

                    else // we have found the duplicate
                    {
                        return(nums[i]);
                    }
                }
                else
                {
                    i++;
                }
            }

            return(i);
        }