Code Lab

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

Largest palindrome number

MédiaArrays10 min

Write a function maxPalindromeNumber(numbers) that returns the largest palindrome number in an array. A palindrome number reads the same from left to right and from right to left, such as 7, 44 or 121.

  • numbers is an array of integers. They can be positive, negative or 0.
  • A number with one digit, also 0, is a palindrome.
  • Negative numbers are not palindromes: -121 read from right to left is 121-.
  • Return the largest palindrome as a number. It does not have to be the largest number of the array.
  • If the array has no palindromes (also for an empty array), return null.

Exemplos

maxPalindromeNumber([12, 121, 33, 45])

Retorna 121

maxPalindromeNumber([12321, 98765, 44])

Retorna 12321

maxPalindromeNumber([12, 34])

Retorna null

Cobrada em Synechron · Fonte

Carregando o editor...
  1. EntradamaxPalindromeNumber([ 12, 121, 33, 45 ])
    Esperado121
  2. EntradamaxPalindromeNumber([ 12321, 98765, 44 ])
    Esperado12321
  3. EntradamaxPalindromeNumber([ 12, 34 ])
    Esperadonull

Os testes ocultos rodam no envio