in Education by
Write a program to eliminate duplicates in a sorted array. in python Select the correct answer from above options

1 Answer

0 votes
by
Answer: Program Explanation: class Solution(object): def removeDuplicates(self, nums): “”” :type nums: List[int] :rtype: int “”” if len(nums) == 0: return 0 length = 1 previous = nums[0] index = 1 for i in range(1,len(nums)): if nums[i] != previous: length += 1 previous = nums[i] nums[index] = nums[i] index+=1 return length input_list = [1,1,2,2,2,3,3,3,3,4,5,5,5,6] ob1 = Solution() print(ob1.removeDuplicates(input_list))

Related questions

0 votes
    Write a program to store 10 names in an array. Arrange these in alphabetical orderby sorting. Print the sorted list. ... , LUCY, etc. Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    Considering the following sorted array and the search key as 89, what will be the sequence of keys in the array ... searching for 89? Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    read the data from employee. text file and sort on age using counting sort,merge sort,quick sort and write ... sortedemponage.txt'. Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    write a Java program to input 10 non-zero numbers in an array and display the count of even and odd numbers. URGENT! Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    write a program to print fibonacci series . write a program to search an element within the array using binary search Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    Write a c program to find largest and smallest among all elements of 2-d array. Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    Write a Numpy program to create an array to 10 zeros,10 ones,10 fives. Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    Write a program to generate first 20 terms of Fibonacci series and store them in single dimension array. Display ... from the array Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Write a python program to print first n(entered by user) even natural numbers. Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    Write a program to accept a filename from the user and display all the lines from the file which contain python comment character ‘#’. Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    write a program in python to find the greatest of three no. given by user Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    Write a program in python to insert ten friends name in a list, then print 3rd, 5th and 9th value from the list (using data structure) Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    write a program to implement a simple calculator for two input number . offers choice through a menu in python Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write a program in Python to print the sum of the following series: s=1+x+x^2+x^3+…..+x^n Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
0 votes
    Write a Python program to get the Python version you are using. Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
...