This commit is contained in:
a.pivkin
2025-07-16 08:15:26 +03:00
parent cebbf27b3a
commit 0635aaa5ae
53 changed files with 76 additions and 4 deletions
+26
View File
@@ -0,0 +1,26 @@
package main
import "fmt"
func main() {
initArr := []int{1,2,3,4,1,1,4,2,5}
fmt.Println(initArr)
CountStrg := make(map[int]int)
for _,val := range initArr {
// fmt.Printf("Key is %d and val is %d\n",key, val)
if _,ok := CountStrg[val]; !ok {
CountStrg[val] = 1
continue
}
CountStrg[val]++
}
fmt.Println(CountStrg)
fmt.Print("==========================\n")
fmt.Println("Len of slice is: ",len(initArr)," and capacity is ",cap(initArr))
initArr = append(initArr, 10)
fmt.Print("==========================\n")
fmt.Println("New len of slice is: ",len(initArr)," and new capacity is ",cap(initArr))
}