Created
February 8, 2020 15:53
-
-
Save cyantarek/eb3f55308b8c8c9bcffd9c89240a6074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package reversestring | |
import ( | |
"strings" | |
) | |
func ReverseString(s string) string { | |
if s == "" { | |
return "" | |
} | |
var newString []string | |
for i := len(s)-1; i >= 0; i-- { | |
newString = append(newString, string(s[i])) | |
} | |
return strings.Join(newString, "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment