Skip to content

Instantly share code, notes, and snippets.

@ereshzealous
Last active April 27, 2020 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ereshzealous/35d9ae2ea7dbea8259f0bc127115c576 to your computer and use it in GitHub Desktop.
Save ereshzealous/35d9ae2ea7dbea8259f0bc127115c576 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"runtime"
"sort"
)
func main() {
var n int
fmt.Scanf("%d", &n)
fmt.Println(n)
for i := 0; i < n; i++ {
var str string
fmt.Scanf("%s", &str)
arr := make([]int, len(str))
for j := 0; j < len(str); j++ {
arr[j] = int(str[j])
}
sort.Ints(arr)
var canSave = true
for j := 0; j < len(arr)-1; j++ {
if arr[j+1]-arr[j] != 1 {
canSave = false
break
}
}
if !canSave {
fmt.Println("NO")
} else {
fmt.Println("YES")
}
}
PrintMemUsage()
}
func PrintMemUsage() {
var m runtime.MemStats
runtime.ReadMemStats(&m)
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
fmt.Printf("Alloc = %v KB", bToMb(m.Alloc))
fmt.Printf("\tTotalAlloc = %v KB", bToMb(m.TotalAlloc))
fmt.Printf("\tSys = %v KB", bToMb(m.Sys))
fmt.Printf("\tNumGC = %v\n", m.NumGC)
}
func bToMb(b uint64) uint64 {
return b / 1024
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment