Last active
September 16, 2017 14:53
-
-
Save anddam/0a5f46a7d05a1df49ee23bd626781afc to your computer and use it in GitHub Desktop.
Hackerrank problem # https://www.hackerrank.com/challenges/cut-the-sticks/submissions/code/54559763
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/python3 | |
import sys | |
from collections import Counter | |
n = int(input().strip()) | |
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')] | |
length, counter = len(arr), Counter(arr) | |
for value in sorted(counter): | |
print(length) | |
length -= counter[value] |
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/python3 | |
import sys | |
from collections import Counter | |
from itertools import accumulate | |
n = int(input().strip()) | |
arr = [int(arr_temp) for arr_temp in input().strip().split(' ')] | |
counter = Counter(arr) | |
print(len(arr)) | |
for value in accumulate([counter[_] for _ in sorted(counter)][:-1]): | |
print(len(arr) - value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment