• + 1 comment

    I thought it like this - for a nXm size. First make (m-1) vertical cuts or (n-1) horizontal cuts then make (n-1)*m horizontal cuts or (m-1)n vertical cuts, respectively. Let me know if the explanation is not clear, will try to improve it.

    My golang solution

    func solve(n int32, m int32) int64 {
        return int64(m-1) + int64(n-1) * int64(m)
    }