Skip to content
Justice Tech School

Practice: Reverse and Palindrome

Reverse runes to support Unicode.

Example
package main

import "fmt"

func main() {
	s := "level"
	r := []rune(s)
	for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	fmt.Println(string(r), string(r) == s)
}

Result

level true

Exercise

Runes.

[](s)

Quiz Test

Why use runes?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.