Created
June 12, 2014 06:12
-
-
Save hindenbug/c039da0685800ff286d0 to your computer and use it in GitHub Desktop.
PermutationCheckMissing
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
| def solution(a) | |
| # write your code in Ruby 1.9.3 | |
| countr = [0] * (a.max) | |
| a.each do |v| | |
| countr[v-1] += 1 | |
| end | |
| if countr.include?(0) || countr.max > 1 | |
| 0 | |
| elsif countr.max == 1 | |
| 1 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment