Created
June 9, 2013 14:19
-
-
Save nida-001/5743719 to your computer and use it in GitHub Desktop.
みんなが楽しいパーティー
This file contains 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
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