Created
March 24, 2017 00:44
-
-
Save prithajnath/4f575f0f45bf1b85d7393095cc71caea to your computer and use it in GitHub Desktop.
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
| #!/bin/python | |
| import sys | |
| from collections import Counter | |
| n = int(raw_input().strip()) | |
| a = map(int,raw_input().strip().split(' ')) | |
| max_num = -1 | |
| freq = Counter(a) | |
| new_arr = freq.keys() | |
| new_arr.sort() | |
| for i in xrange(len(new_arr)-1): | |
| x,y = new_arr[i],new_arr[i+1] | |
| if abs(x-y)<=1: | |
| max_num = max(max_num,freq[x]+freq[y]) | |
| print max_num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment