Create another array with a length of 50, initialize all to 0, traverse the given array, set the new array subscript equal to the current value of the given array to 1, and finally output the new array subscript with a value of 0. That was my first reaction, to wait for a better solution.
Find the sum from 1 to 50, then traverse the array to sum and subtract, how to
Create another array with a length of 50, initialize all to 0, traverse the given array, set the new array subscript equal to the current value of the given array to 1, and finally output the new array subscript with a value of 0. That was my first reaction, to wait for a better solution.
Use the sum of 1 to 50 to subtract all the numbers in the array:
Time Complexity:
O(n)
Space Complexity:
O(1)
Questions I answered: Python-QA