Skip to content
Exercise · Arrays and slices · lesson 10 of 10

Exercise: maximum of arguments

Write a function func maxOf(first int, rest ...int) int that returns the largest of its arguments.

  • maxOf(3, 9, 4) → 9
  • maxOf(7) → 7
  • maxOf(-5, -2, -9) → -2

Constraints: there are from one to 1000 arguments, each from -1000000 to 1000000, and all of them may be negative; rest may be empty.

Do not add extra imports unless the task says so explicitly.

maxof.go — go
go · 6 lines
Ctrl+Enter run · Esc leave editor

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way