Removing duplicate from Array

This one of the most important question asked many times in interview. To check if candidate knows basic of Python core programming.

The program is very simple however I request every one just keep resisting this question and keep this logic in your mind

def remove_duplicates(arr):
    unique_elements = []

    for num in arr:
        if num not in unique_elements:
            unique_elements.append(num)

    return unique_elements

array = [2, 3, 1, 3, 5, 2, 4, 4, 1]

result = remove_duplicates(array)

print(result)

# Output: [2, 3, 1, 5, 4]

This code snippet efficiently removes duplicate elements from an array, leaving only the unique values. It’s a valuable tool for anyone looking to work with arrays in Python and a concept that is frequently examined during programming interviews