Tous les défis
Facile 0 résolus 0 % de réussite

Reverse a String

Return the characters of a string in reverse order.

Reverse text so the last character comes first.

Implement reverse_string(text).

Input

text: The text to reverse.

Output

Return the reversed text.

Contraintes

0 ≤ length ≤ 10,000

Exemples

Exemple 1
Entrée :
text = "hello"

Sortie attendue :
expected = "olleh"
Entrée :
std::string text = "hello";

Sortie attendue :
std::string expected = "olleh";
Entrée :
string text = "hello";

Sortie attendue :
string expected = "olleh";

Explication

h-e-l-l-o read backwards is "olleh".

Exemple 2
Entrée :
text = "a"

Sortie attendue :
expected = "a"
Entrée :
std::string text = "a";

Sortie attendue :
std::string expected = "a";
Entrée :
string text = "a";

Sortie attendue :
string expected = "a";

Explication

A single character reversed is itself.

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.