Skip to content

Instantly share code, notes, and snippets.

@nida-001
Created June 9, 2013 14:19
Show Gist options
  • Save nida-001/5743719 to your computer and use it in GitHub Desktop.
Save nida-001/5743719 to your computer and use it in GitHub Desktop.
みんなが楽しいパーティー
package main
import (
"math"
)
func main() {
first := []string {"f", "g", "s", "f"}
second := []string {"h", "f", "f", "b"}
println(bestInvitation(first, second))
}
func bestInvitation(first, second []string) int {
var ans int = 0
for i := 0; i < len(first); i++ {
f := 0
s := 0
for j := 0; j < len(first); j++ {
if first[i] == first[j] { f++ }
if first[i] == second[j] { f++ }
if second[i] == second[j] { s++ }
if second[i] == second[j] { s++ }
}
ans = int(math.Max(float64(f), float64(ans)))
ans = int(math.Max(float64(s), float64(ans)))
}
return ans
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment