Problema
Mostra originale (inglese)Inverti text così che l'ultimo carattere diventi il primo.
Implementa reverse_string(text).
Input
text: Il testo da invertire.
Output
Restituisci il testo invertito.
Vincoli
0 ≤ lunghezza ≤ 10.000
Esempi
Esempio 1
Input:
text = "hello"
Output atteso:
expected = "olleh"
Input:
std::string text = "hello";
Output atteso:
std::string expected = "olleh";
Input:
string text = "hello";
Output atteso:
string expected = "olleh";
Spiegazione
h-e-l-l-o letto al contrario è "olleh".
Esempio 2
Input:
text = "a"
Output atteso:
expected = "a"
Input:
std::string text = "a";
Output atteso:
std::string expected = "a";
Input:
string text = "a";
Output atteso:
string expected = "a";
Spiegazione
Un singolo carattere invertito rimane se stesso.
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.