Skip to content

Instantly share code, notes, and snippets.

@fhorlaville
Created April 2, 2017 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhorlaville/188da43bef4ee81c5406fdc2dc1dd855 to your computer and use it in GitHub Desktop.
Save fhorlaville/188da43bef4ee81c5406fdc2dc1dd855 to your computer and use it in GitHub Desktop.
let n = Int(readLine()!)!
let line0 = readLine()!.components(separatedBy: " ").map{ Int($0)! }.sorted(by: { $0 > $1 })
var answer = 0
var previous = line0[0]
for i in 0..<n {
if line0[i] == previous {
answer += 1
previous = line0[i]
} else {
break
}
}
print(answer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment