Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Duplicates from a Sorted List #231

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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.

None yet

3 participants