Skip to content

Instantly share code, notes, and snippets.

@hindenbug
Created June 12, 2014 06:12
Show Gist options
  • Select an option

  • Save hindenbug/c039da0685800ff286d0 to your computer and use it in GitHub Desktop.

Select an option

Save hindenbug/c039da0685800ff286d0 to your computer and use it in GitHub Desktop.
PermutationCheckMissing
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