Code Lab

Mode entretien. Minuteur de 7 min, sans indices ni autocomplétion

0, 0, 7 in order

FacileArrays7 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.

Exemples

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

Renvoie true

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

Renvoie false

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

Renvoie false

Only one zero comes before the seven.

Posé chez Druva · Source

Chargement de l'éditeur...
  1. Entréehas007([ 1, 0, 2, 4, 0, 5, 7 ])
    Attendutrue
  2. Entréehas007([ 1, 7, 0, 0 ])
    Attendufalse
  3. Entréehas007([ 0, 1, 7, 0 ])
    Attendufalse

Les tests cachés se lancent à la soumission