Problem description

Determines whether two given strings are consistent when sorted.

Given two strings, write a program to determine whether the characters of one string can be rearranged into the other string.

Case is specified as different characters.

Given a string s1 and a string s2, return a bool indicating whether the two strings can be identical when rearranged.

Ensure that both strings are less than or equal to 5000.

Their thinking

The number of characters in s1 is the same as that in S2.

The complete code

func judge(s1, s2 string) bool {
	r1 := []rune(s1)
	r2 := []rune(s2)
	n1 := len(r1)
	n2 := len(r2)
	if n1 > 5000 || n2 > 5000|| n1 ! = n2 {return false
	}
	for _, r := range r1 {
		if strings.Count(s1, string(r)) ! = strings.Count(s2,string(r)) {
			return false}}return true
}
Copy the code