Created
February 8, 2020 15:55
-
-
Save cyantarek/1bc61eedc11737dc626a13d9f5933f13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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