Skip to content

Conversation

@sonjyoti
Copy link

Added Remove Duplicates from a Sorted List. Leetcode Problem .83

@Ziniddoug
Copy link

def remove_duplicates(lst):
    unique_lst = []
    for element in lst:
        if element not in unique_lst:
            unique_lst.append(element)
    return unique_lst

# Example usage
lst = [1, 2, 2, 3, 4, 4, 4, 5, 6, 6]
unique_lst = remove_duplicates(lst)
print(unique_lst)

In this example, the remove_duplicates function takes a list as a parameter and iterates over each element in the list. If the element is not already present in the unique_lst, it is added to that list. Finally, the function returns the list without duplicates.

In the provided usage example, the original list is [1, 2, 2, 3, 4, 4, 4, 5, 6, 6]. The output will be [1, 2, 3, 4, 5, 6], which is the original list without duplicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants