This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Queue implementation | |
class Queue: | |
def __init__(self): | |
self.queue = [] | |
# Add an element | |
def enqueue(self, item): | |
self.queue.append(item) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nums = [0, 0, 1, 1, 2, 2, 3, 3, 4] | |
#using list comprehension to remove duplicates | |
non_dup = [] | |
[non_dup.append(x) for x in nums if x not in non_dup] | |
print(str(non_dup)) | |
print(len(non_dup)) |