Error while returning list to main function

class Solution(object):
    def removeDuplicates(self, nums):
        s=[]
        for i in range(len(nums)):
            if nums[i] not in s:
                s.append(nums[i])
        return(s)

Here “nums” is the list provided with values like nums=[1,1,2,3] and I am trying to append values which are separate from others in the list s. But when I am trying to return the list “s” I am getting an error which is:

“TypeError: [1, 2] is not valid value for the expected return type integer[]
raise TypeError(str(ret) + " is not valid value for the expected return type integer[]”);
Line 31 in _driver (Solution.py)
_driver()
Line 37 in (Solution.py)"

Can anyone tell me what this error means and how can I rectify it?

Can you share the link?

link-> - LeetCode

This was mentioned there

Clarification:

Confused why the returned value is an integer but your answer is an array?

Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.

Internally you can think of this:

// nums is passed in by reference. (i.e., without making a copy) int len = removeDuplicates(nums); // any modification to nums in your function would be known by the caller. // using the length returned by your function, it prints the first len elements. for (int i = 0; i < len; i++) { print(nums[i]); }

So you are supposed to return the number of elements that are present in the list after removing duplicates. It was also mentioned to modify the given array.

But when I am returning the len value of s, I am getting a different answer from print(s), also since I am not modifying the original list, there shouldn’t be any error right?

No. You are supposed to modify the given list.
Hint: Use two pointers.

Going to try that one, thanks mate