func smallestEvenMultiple(n int) int { if n & 1 == 1 { // 如果 n 是奇数,则 2 和 n 的最小公倍数为 2n return n << 1 } // 如果 n 是偶数,则 2 和 n 的最小公倍数为 n return n } 题目链接: Smallest Even Multiple: leetcode.com/problems/s 最小偶倍数: leetcode.cn/problem...
We can use dfs to get all strings, sort them then get the smallest one. Even better, we can just keep a global variable of the current smallest string, each time we get a new string, compare it with the current smallest string and update it if necessary. This way it avoids keeping a...