Advertisement
jbn6972

Untitled

Aug 6th, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #Code Written by : John Nixon
  2. #Date: 06:08:2022  Time: 12:08:33
  3. #Copyrights are applicable
  4.  
  5. import sys
  6. import os
  7. sys.setrecursionlimit(10000)
  8. try:
  9.     sys.stdin = open('./input.txt', 'r')
  10.     sys.stdout = open('./output.txt', 'w')
  11. except:
  12.     pass
  13.  
  14. n = int(input())
  15.  
  16. socks = list(map(str,input().split()))
  17. # print(socks)
  18.  
  19. freq = {}
  20. unPaired = []
  21. for sock in socks:
  22.     if sock in freq:
  23.         if sock in unPaired:
  24.             unPaired.remove(sock)
  25.         del freq[sock]
  26.     else:
  27.         freq[sock] = 1
  28.         unPaired.append(sock)
  29.  
  30. if len(unPaired) > 0:
  31.     for sock in unPaired:
  32.         print("1 "+sock,end=" ")
  33.     print("is not having any pair")
  34. else:
  35.     print("it is paired")
  36.  
  37.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement