ACCENTURE | COGNIZANT | IBM | CAPGEMINI
Kanalga Telegram’da o‘tish
Ko'proq ko'rsatish
7 673
Obunachilar
-1024 soatlar
-377 kunlar
+2430 kunlar
Postlar arxiv
def generateBinaryPathCode(n):
t = 1 << n
l = []
s = set()
dp = [0] * n
def isValid(prev, curr):
d = prev ^ curr
if bin(d).count('1') != 1:
return False
b= d.bit_length() - 1
tb = (curr >> b) & 1
k = 1 if dp[b] % 2 == 0 else 0
return tb == k
def backtrack():
if len(l) == t:
return bin(l[0] ^ l[-1]).count('1') == 1
prev = l[-1]
for i in range(n):
b = 1 << i
c = prev ^ b
if c in s:
continue
if not isValid(prev, c):
continue
l.append(c)
s.add(c)
dp[i] += 1
if backtrack():
return True
l.pop()
s.remove(c)
dp[i] -= 1
return False
l.append(0)
s.add(0)
if backtrack():
return l
return []
7/7 cases passed✅✅
contact : @MLCODER2
def findResistorColorBands(power, current):
d = {
0: 'BLK', 1: 'BWN', 2: 'RED', 3: 'ONG', 4: 'YLW',
5: 'GRN', 6: 'BLU', 7: 'VLT', 8: 'GRY', 9: 'WHT'
}
if power <= 0 or current <= 0 or current > power:
print("Invalid input")
return ""
res = power // current
res_str = str(res)
if len(res_str) < 2:
print("Invalid input")
return ""
dig = res_str[:2]
mul = len(res_str) - 2
try:
b1 = d[int(dig[0])]
b2 = d[int(dig[1])]
b3 = d[mul]
print(f"{b1} {b2} {b3}")
return ""
except:
print("Invalid input")
return ""
#findResistanceColorBands✅✅✅
def generateBinaryPathCode(n):
def flip_tracker():
return [True] * n
def bit_diff(a, b):
return bin(a ^ b).count('1')
def get_bit_flipped_index(a, b):
return (a ^ b).bit_length() - 1
def backtrack(path, used, direction):
if len(path) == 2 ** n:
if bit_diff(path[-1], path[0]) == 1:
return path
return None
last = path[-1]
for i in range(n):
mask = 1 << i
if direction[i]:
candidate = last | mask
else:
candidate = last & ~mask
if candidate not in used:
direction[i] = not direction[i]
path.append(candidate)
used.add(candidate)
result = backtrack(path, used, direction)
if result:
return result
path.pop()
used.remove(candidate)
direction[i] = not direction[i]
return None
return backtrack([0], {0}, flip_tracker())
#generateBinaryPath
#IBM
Who need help for CAPGEMINI, IBM CIC should contact me ✅✅
Contact : @MLCODER2
+5
CAPGEMINI 6 SLOTS CLEARRF ROUND-1 ✅✅
Contact: @MLCODER2
IBM OFFLINE CODING SLOTS AVAILABLE✅✅
Contact : @MLCODER2
+3
Integraminds✅✅✅
Verbal + Aptitude + Java coding + Essay writing✅✅
Contact : @MLCODER2
Endi mavjud! Telegram Tadqiqoti 2025 — yilning asosiy insaytlari 
