> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0859_buddy_strings/slt.md).

# Solution 1 simulation

* t-complexity: $O(n + C)$ C is size of charset
* s-complexity: $O(C)$

直接暴力会超时

* s 和 goal 长度或者词频不同，则不为 buddy string
* s 与 goal 不同的字符数量为 2 （能相互交换）
* s and goal diff char number is 0, and s has char which appear more than twice
