Untitled
unknown
plain_text
5 months ago
688 B
8
Indexable
class Solution: def maxGoodNumber(self, nums: List[int]) -> int: freq = [0] * 3 p = [] def permutation(curr): if len(curr) == 3: p.append(curr[:]) return for i in range(3): if freq[i] == 1: continue curr.append(nums[i]) freq[i] = 1 permutation(curr) freq[i] = 0 curr.pop() permutation([]) mx = 0 for arr in p: bs = "" for e in arr: bs += bin(e)[2:] mx = max(int(bs, 2), mx) return mx
Editor is loading...
Leave a Comment