Skip to content

Instantly share code, notes, and snippets.

@amulyakashyap09
Last active December 31, 2017 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amulyakashyap09/0ec512c588d8ab7c8b836489afad6eaa to your computer and use it in GitHub Desktop.
Save amulyakashyap09/0ec512c588d8ab7c8b836489afad6eaa to your computer and use it in GitHub Desktop.
Set .add() | hackerrank
# METHOD 1
n = int(input())#take input in n
a = set()
for i in range(n):
ci = input()
if ci not in a:
a.add(ci)
print(len(a))
# METHOD 2
n = int(input())
a = list()
for i in range(n):
ci = input()
indexValue = a.index(ci) if ci in a else -1
if indexValue == -1:
a.append(ci)
print(len(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment