Code Lab

Modo entrevista. Temporizador de 7 min, sin pistas y sin autocompletado

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.

Ejemplos

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

Devuelve true

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

Devuelve false

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

Devuelve false

Only one zero comes before the seven.

Preguntada en Druva · Fuente

Cargando el 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

Las pruebas ocultas se ejecutan al enviar