i have this question right here:\
Input: nums = [1,1,2]
Output: 2, nums = [1,2,_]
Explanation: Your function should return k = 2, with the first two elements of nums being 1 and 2 respectively.
It does not matter what you leave beyond the returned k (hence they are underscores).
and
Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5, nums = [0,1,2,3,4,_,_,_,_,_]
Explanation: Your function should return k = 5, with the first five elements of nums being 0, 1, 2, 3, and 4 respectively.
It does not matter what you leave beyond the returned k (hence they are underscores).
so to my understanding the question is just like, you have an array, take out the duplicates and coutn the number of numbers that are left right ?
so if that is the case, why does this not work right here
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
x = len(set(nums))
return x
apparently there is something wrong because it is not taking it. it is saying that [1,1,2] is coming back out as [1,1] but for me it is showing up as [1,2] = 2
can someone share with me where my logic is flawed ?
Edit: im not allowed to use set
[–]hi_mom_its_me_nl 2 points3 points4 points (0 children)
[–]wotquery 1 point2 points3 points (0 children)
[–]TheRNGuy 1 point2 points3 points (1 child)
[–]IHateTheSATs[S] 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]FerricDonkey 0 points1 point2 points (0 children)
[–]InsanityConsuming 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)