def remove_duplicates(input_list):
# Initialize an empty list to store the result
result = []
# Initialize an empty set to track seen elements
seen = set()
# Iterate over each element in the input list
for item in input_list:
# If the item is not in the seen set, it's not a duplicate
if item not in seen:
# Add the item to the result list
result.append(item)
# Mark the item as seen by adding it to the set
seen.add(item)
# Return the result list with duplicates removed
return result
# Example usage
print(remove_duplicates([1, 2, 2, 3, 4, 4, 5])) # Output: [1, 2, 3, 4, 5]
ZGVmIHJlbW92ZV9kdXBsaWNhdGVzKGlucHV0X2xpc3QpOgogICAgIyBJbml0aWFsaXplIGFuIGVtcHR5IGxpc3QgdG8gc3RvcmUgdGhlIHJlc3VsdAogICAgcmVzdWx0ID0gW10KICAgICMgSW5pdGlhbGl6ZSBhbiBlbXB0eSBzZXQgdG8gdHJhY2sgc2VlbiBlbGVtZW50cwogICAgc2VlbiA9IHNldCgpCiAgICAKICAgICMgSXRlcmF0ZSBvdmVyIGVhY2ggZWxlbWVudCBpbiB0aGUgaW5wdXQgbGlzdAogICAgZm9yIGl0ZW0gaW4gaW5wdXRfbGlzdDoKICAgICAgICAjIElmIHRoZSBpdGVtIGlzIG5vdCBpbiB0aGUgc2VlbiBzZXQsIGl0J3Mgbm90IGEgZHVwbGljYXRlCiAgICAgICAgaWYgaXRlbSBub3QgaW4gc2VlbjoKICAgICAgICAgICAgIyBBZGQgdGhlIGl0ZW0gdG8gdGhlIHJlc3VsdCBsaXN0CiAgICAgICAgICAgIHJlc3VsdC5hcHBlbmQoaXRlbSkKICAgICAgICAgICAgIyBNYXJrIHRoZSBpdGVtIGFzIHNlZW4gYnkgYWRkaW5nIGl0IHRvIHRoZSBzZXQKICAgICAgICAgICAgc2Vlbi5hZGQoaXRlbSkKICAgIAogICAgIyBSZXR1cm4gdGhlIHJlc3VsdCBsaXN0IHdpdGggZHVwbGljYXRlcyByZW1vdmVkCiAgICByZXR1cm4gcmVzdWx0CgojIEV4YW1wbGUgdXNhZ2UKcHJpbnQocmVtb3ZlX2R1cGxpY2F0ZXMoWzEsIDIsIDIsIDMsIDQsIDQsIDVdKSkgICMgT3V0cHV0OiBbMSwgMiwgMywgNCwgNV0=