LeetCode75-1657-Close-Two-String
🧠 思路总结
判断两个字符串是否 close:
- 长度是否相同
- 是否包含完全相同的字母集合
- 字母出现次数是否只是一个排列
需要找什么可以一直不变
- Operation 1: Swap any two existing characters.
For example, abcde -> aecdb。本质上是需要确保word1中有的charword2中也得有 - Operation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character. For example, aacabb -> bbcbaa (all a’s turn into b’s, and all b’s turn into a’s)。本质上是需要确保
word1中有的charword2中也得有 并且 需要确保occurrence排序后一模一样
✅ 代码(Java)
1 | |
LeetCode75-1657-Close-Two-String
https://powersixxx.github.io/leetcode-blog/2026/02/06/LeetCode75-1657-Close-Two-String/