The cinema seat map has one string per row: . is a free seat, x is taken. There are need of you and you want the same row (not necessarily side by side). Write RowForFriends(rows, need) to return the number of the first row with enough free seats (counting from 1), or 0 if none has.
RowForFriends([]string{"xx.x", "..x.", "...."}, 3)→2RowForFriends([]string{"xxx", "x.x"}, 2)→0func RowForFriends(rows []string, need int) intpackage main
func RowForFriends(rows []string, need int) int {
for i, row := range rows {
free := 0
// your code here: range over the seats in this row, adding 1 to free for each '.'
// your code here: enough free seats? return the row number
}
return 0
}
Run tries the examples. When they look right, Submit.