Solución

@frayley_4b38e1ec·2/9/2026TypeScript
solution.tsTypeScript
public class Solution {
    public String rot13(String text) {
        
    List<String> abcMa = List.of(
      "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M","N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X","Y", "Z",
      "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M","N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" );

    List<String> abcMi = List.of(
      "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m","n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
      "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m","n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" );

    StringBuilder result = new StringBuilder();

    for(char ca : text.toCharArray()){

      int potition = 0;
      if(Character.isUpperCase(ca)) {
        potition = abcMa.indexOf(String.valueOf(ca));
        result.append(String.valueOf(abcMa.get(potition + 13)));
      }else if (Character.isLowerCase(ca)){
        potition = abcMi.indexOf(String.valueOf(ca));
        result.append(String.valueOf(abcMi.get(potition + 13)));
      }else{
        result.append(String.valueOf(ca));
      }

    }

    return result.toString();

    }
}
0respuestas
Respuestas

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.