Untitled
unknown
plain_text
a year ago
688 B
10
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 mxEditor is loading...
Leave a Comment