The challenge Given a slice of positive integers, return the value with the most digits. If two or more values share the highest digit count, return the first one in the slice. Examples: findLongest([]int{1, 10, 100}) // → 100 findLongest([]int{9000, 8, 800}) // → 9000 findLongest([]int{8, 900, 500}) // → 900 This Codewars-style puzzle is asked in Go interviews and screens for understanding of slices, ties, and avoiding allocations. Solution 1: count digits with integer division The most idiomatic Go version — no strconv allocation:
No comments yet. Log in to reply on the Fediverse. Comments will appear here.