https://leetcode-cn.com/problems/ransom-note/
func canConstruct(ransomNote string, magazine string) bool { m := len(ransomNote) n := len(magazine) if m > n { return false } index := []int{} for i := 0; i < m; i++ { ok := false for ii := 0; ii < n; ii++ { if ransomNote[i] == magazine[ii] { j := len(index) for iii := 0; iii < j; iii++ { if ii != index[iii] { index = append(index, ii) ok = true break } } } if ok { break } } if !ok { return false } } return true }
原创文章,作者:bd101bd101,如若转载,请注明出处:https://blog.ytso.com/245320.html