Code Lab

Modo entrevista. Cronômetro de 7 min, sem dicas e sem autocompletar

0, 0, 7 in order

FácilArrays7 min

Write a function has007(numbers) that returns true if the array has 0, 0 and 7 in this order, and false if not. Other numbers may stand between them.

Exemplos

has007([1, 0, 2, 4, 0, 5, 7])

Retorna true

has007([1, 7, 0, 0])

Retorna false

The seven comes before the zeros.
has007([0, 1, 7, 0])

Retorna false

Only one zero comes before the seven.

Cobrada em Druva · Fonte

Carregando o editor...
  1. Entradahas007([ 1, 0, 2, 4, 0, 5, 7 ])
    Esperadotrue
  2. Entradahas007([ 1, 7, 0, 0 ])
    Esperadofalse
  3. Entradahas007([ 0, 1, 7, 0 ])
    Esperadofalse

Os testes ocultos rodam no envio