Last active
April 27, 2020 12:10
-
-
Save ereshzealous/35d9ae2ea7dbea8259f0bc127115c576 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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