Portfolio algoritmos

  • Sherlock and the valid String

    Sherlock considers a string to be valid if all characters of the string appear the same number of times. It is also valid if he can remove just character at index in the string, and the remaining characters will occur the same number of times. Given a string , determine if it is valid. If so, return YES, otherwise return NO.


    Example
    This is a valid string because frequencies are .
    This is a valid string because we can remove one and have of each character in the remaining string.
    This string is not valid as we can only remove occurrence of . That leaves character frequencies of .
    Function Description
    Complete the isValid function in the editor below.
    isValid has the following parameter(s):
    string s: a string

    HackerRank
    Imagen del código de ordenamiento.
  • birthday Cake Candles

    You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest.


    Example
    The maximum height candles are units high. There are of them, so return .
    Function Description
    Complete the function birthdayCakeCandles in the editor below.
    birthdayCakeCandles has the following parameter(s):
    int candles[n]: the candle heights

    HackerRank
    Imagen del código de ordenamiento.
  • Dale la vuelta a los paréntesis

    En el taller de Santa 🎅, algunos mensajes navideños han sido escritos de manera peculiar: las letras dentro de los paréntesis deben ser leídas al revés
    Santa necesita que estos mensajes estén correctamente formateados. Tu tarea es escribir una función que tome una cadena de texto y revierta los caracteres dentro de cada par de paréntesis, eliminando los paréntesis en el mensaje final.
    Eso sí, ten en cuenta que pueden existir paréntesis anidados, por lo que debes invertir los caracteres en el orden correcto.

    Advent JS
    Imagen del código de ordenamiento.

Para ver más codigos visite mi Github de pruebas técnicas