What do the test cases test ? ?


  • -1
    Y

    below is my code segment for the problem. The question emphasized that only the new length will be important, but the test cases seemed to test the new array, making my code not acceptable. Any idea?
    '''
    class Solution(object):
    def removeDuplicates(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    if not nums:
    return 0
    count = 0
    for i in range(len(nums)-1):
    if nums[i] == nums[i+1]:
    count+=1
    return len(nums)-count
    '''


  • 0
    Y

    @yunchuankong said in What do the test cases test ? ?:

    below is my code segment for the problem. The question emphasized that only the new length will be important, but the test cases seemed to test the new array, making my code not acceptable. Any idea?
    '''
    class Solution(object):
    def removeDuplicates(self, nums):
    """
    :type nums: List[int]
    :rtype: int
    """
    if not nums:
    return 0
    count = 0
    for i in range(len(nums)-1):
    if nums[i] == nums[i+1]:
    count+=1
    return len(nums)-count
    '''

    This is python code.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.