class Solution: def smallestEvenMultiple(self, n: int) -> int: if n & 1: # 如果 n 是奇数,则 2 和 n 的最小公倍数为 2n return n << 1 # 如果 n 是偶数,则 2 和 n 的最小公倍数为 n return n 代码(Go) func smallestEvenMultiple(n int) int { if n & 1 == 1 { // 如果...
The number of nodes in the given tree will be between1and1000. Each node in the tree will have a value between0and25. 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 ...