<commit_before>package shuffle

func shuffleString(s string, indices []int) string {
	return s
}
<commit_msg>solve 1528 use basic traversal<commit_after>package shuffle

func shuffleString(s string, indices []int) string {
	return useTraverse(s, indices)
}

func useTraverse(s string, indices []int) string {
	n := len(s)
	if n < 1 {
		return s
	}
	sb := []byte(s)
	undo := make([][]int, 26)
	for i := 0; i < n; i++ {
		if i == indices[i] {
			continue
		}
		from, to := i, indices[i]
		if indices[to] == from {
			// swap
			sb[from], sb[to] = sb[to], sb[from]

		} else {
			undo[s[to]-'a'] = append(undo[s[to]-'a'], indices[to])
			sb[to] = sb[from]
		}
		indices[to] = to
	}
	for i, pp := range undo {
		for _, p := range pp {
			sb[p] = byte('a' + i)
		}
	}
	return string(sb)
}

{'fraction_non_alphanumeric': 0.18112244897959184, 'fraction_numerical': 0.01020408163265306, 'mean_word_length': 3.2432432432432434, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5261068', 'n_tokens_mistral': 354, 'n_tokens_neox': 316, 'n_words': 87}