-1

I solved Sales by Match problem in this way:

package main

import (
    "fmt"
)

func main() {
    var amount int
    _, _ = fmt.Scanf("%d", &amount)

    pairs := 0
    set := make(map[int]bool)
    for i := 0; i < amount; i++ {
        var number int
        _, _ = fmt.Scanf("%d", &number)

        if set[number] {
            set[number] = false
            pairs++
        } else {
            set[number] = true
        }
    }
    println(pairs)
}

I tested it with the following input:

9 10 20 20 10 10 30 50 10 20

Here's the result:

enter image description here

So, as you can see, everything works fine. But when I run the tests I see the following result:

enter image description here

I don't understand why they are not passed, so, please, can anyone explain what's the problem in my solution? Thanks in advance I would appreciate any help

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Sergei Mikhailovskii
  • 2,100
  • 2
  • 21
  • 43

1 Answers1

1

Change println(pairs) to fmt.Print(pairs)because println writes to stderr and hackerrank looks at stdout for the result.

Manvir
  • 769
  • 1
  • 7
  • 15