Codeforces|Leetcode|Codechef free solutions
Open in Telegram
Free codeforces, Codechef, Leetcode solutions are available ππππππ Helped More than 200+ students to crack coding round in 2022 and helped placed them in Good companies. π₯³π₯³π₯³π€©π€©π€© Dm @Cpsoln if you want help in coding round.
Show more4 317
Subscribers
No data24 hours
-137 days
-5230 days
Posts Archive
How many points you have scored in coding ninja codekaze round 2?
class Solution:
def init(self):
self.dp = [[-1] * ((1 << 14) + 5) for _ in range(20)]
def solve(self, nums, ult, i, mask):
if i == len(nums):
return 1
if self.dp[ult + 1][mask] != -1:
return self.dp[ult + 1][mask]
tot = 0
for j in range(len(nums)):
if mask & (1 << j):
continue
if ult == -1 or nums[ult] % nums[j] == 0 or nums[j] % nums[ult] == 0:
tot += self.solve(nums, j, i + 1, mask | (1 << j))
tot %= 1000000007
self.dp[ult + 1][mask] = tot
return self.dp[ult + 1][mask]
def specialPerm(self, nums):
self.dp = [[-1] * ((1 << 14) + 5) for _ in range(20)]
return self.solve(nums, -1, 0, 0)
count operations done β
contributions code done β
Secret code done β
