Skip to content

Create Picking_numbers.py #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create Picking_numbers.py
  • Loading branch information
atarax665 authored May 12, 2020
commit 21bb4891e5013a2f31f64cc95def001f9a3d57df
30 changes: 30 additions & 0 deletions Picking Numbers/Picking_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/python

import math
import os
import random
import re
import sys

# Complete the pickingNumbers function below.
def pickingNumbers(a):
count = [0 for i in xrange(101)]
for i in a:
count[i] += 1
ans = 0
for i in xrange(0, 100):
ans = max(ans, count[i] + count[i + 1])
return ans

if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')

n = int(raw_input().strip())

a = map(int, raw_input().rstrip().split())

result = pickingNumbers(a)

fptr.write(str(result) + '\n')

fptr.close()