Competitive Programming in Go

Its sweet

Things to refer

Min/Max Int and Uint

const MaxUint = ^uint(0)
const MinUint = 0

const MaxInt = int(^uint(0) >> 1)
const MinInt = -MaxInt - 1

2d-vector-input.go

package main

import (
    "fmt"
)

func main() {

    var cols, rows = 0, 0
    fmt.Print("Enter the number of cols : ")
    _, _ = fmt.Scan(&cols)
    fmt.Print("Enter the number of rows : ")
    _, _ = fmt.Scan(&rows)

    var twodslices = make([][]int, rows)
    var i int
    for i = range twodslices {
        twodslices[i] = make([]int, cols)
    }

    for i := 0; i < rows; i++ {
        for j:=0; j<cols; j++ {
            fmt.Scan(&twodslices[i][j])
        }
    }
    fmt.Println(twodslices)
}

custom-vector-input.go

integer-input.go

map-slice.go

string-input.go

vector-input-integer.go

Last updated

Was this helpful?