Estritamente crescente ou decrescente

Published by Helen Yu in

Crie uma função que recebe um array e determina se ele é estritamente crescente, estritamente decrescente ou nenhum dos dois.

Exemplos

check([1, 2, 3]) ➞ "increasing"

check([3, 2, 1]) ➞ "decreasing"

check([1, 2, 1]) ➞ "neither"

check([1, 1, 2]) ➞ "neither"

Observações

  • Valores vizinhos iguais não são nem estritamente crescentes nem estritamente decrescentes.
  • Os arrays de entrada têm comprimento mínimo de 2.