Advertisement
jbn6972

Untitled

Aug 6th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. n = int(input())
  2.  
  3. socks = list(map(str,input().split()))
  4. # print(socks)
  5.  
  6. freq = {}
  7. unPaired = []
  8. for sock in socks:
  9.     if sock in freq:
  10.         if sock in unPaired:
  11.             unPaired.remove(sock)
  12.         del freq[sock]
  13.     else:
  14.         freq[sock] = 1
  15.         unPaired.append(sock)
  16.  
  17. if len(unPaired) > 0:
  18.     for sock in unPaired:
  19.         print("1 "+sock,end=" ")
  20.     print("is not having any pair")
  21. else:
  22.     print("it is paired")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement