hash_table = {}
nums = [2,3,1,1]
for i in nums:
hash_table[i] = 1 + hash_table.get(i,0)
print(hash_table)
output:
{2: 1, 3: 1, 1: 2}
Process finished with exit code 0
hash_table = {}
nums = [2,3,1,1]
for i in nums:
hash_table[i] = 1 + hash_table.get(i,0)
print(hash_table)
output:
{2: 1, 3: 1, 1: 2}
Process finished with exit code 0