Esempio n. 1
0
func Permutation1(s1, s2 string) bool {
	if len(s1) != len(s2) {
		return false
	}

	sorted1 := str.SortString(s1)
	sorted2 := str.SortString(s2)
	if sorted1 != sorted2 {
		return false
	}

	return true
}
Esempio n. 2
0
func IsUnique2(s string) bool {
	sorted := str.SortString(s)

	for i := 1; i < len(sorted); i++ {
		if sorted[i] == sorted[i-1] {
			return false
		}
	}

	return true
}