Challenge 1: Find the longest string in a string list

Write an OCaml function, longest_string: string list -> string option, to find the longest string in a list of strings.


longest_string [] = None
longest_string ["a"; "ABC"; "ab"] = Some "abc"

Hint: You can use OCaml’s String.length function to compute the length of a string.

Get hands-on with 1200+ tech skills courses.