The following exercises cover strings and maps.
-
For s:= "café", print
len(s) andlen([]rune(s)). Explain the difference using what you know about UTF-8. -
Convert the string "Go ߦ顢 to []byte and []rune. Print both representations, then convert each back to a string and confirm the round-trip matches the original.
-
Use a map as a set to compute the union of []int{1, 2, 3, 4} and []int{3, 4, 5, 6} as a deduplicated []int. Order doesn’t matter.
Progress is saved on this device.