main.go 599 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "os"
  6. "strconv"
  7. "strings"
  8. )
  9. func main() {
  10. input := bufio.NewScanner(os.Stdin)
  11. var output int
  12. var digits []int
  13. for input.Scan() {
  14. line := input.Text()
  15. digits = []int{}
  16. values := strings.Split(line, " ")
  17. for _, v := range values {
  18. d, _ := strconv.Atoi(v)
  19. digits = append(digits, d)
  20. }
  21. output = findRepeatNumber(digits)
  22. fmt.Println(output)
  23. }
  24. }
  25. func findRepeatNumber(nums []int) int {
  26. var record = map[int]bool{}
  27. for _, v := range nums {
  28. if _, ok := record[v]; !ok {
  29. record[v] = true
  30. continue
  31. }
  32. return v
  33. }
  34. return 0
  35. }