Skip to content

Commit ab56bba

Browse files
committed
Runtime: 56 ms (Top 51.37%) | Memory: 13.9 MB (Top 48.63%)
1 parent 1bbb45f commit ab56bba

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

scripts/algorithms/N/Number of Squareful Arrays/Number of Squareful Arrays.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
# Runtime: 56 ms (Top 51.37%) | Memory: 13.9 MB (Top 48.63%)
12
class Solution:
23
def isSquare(self,num):
34
return int(num**0.5)**2 == num
45
def makePermutation(self,used,vis,prev,n):
5-
if used == n:
6+
if used == n:
67
#we reached the end
78
self.ans += 1
89
return
@@ -14,7 +15,7 @@ def makePermutation(self,used,vis,prev,n):
1415
vis[i] = True
1516
self.makePermutation(used+1,vis,self.nums[i],n)
1617
vis[i] = False
17-
18+
1819
def numSquarefulPerms(self, nums: List[int]) -> int:
1920
d = { x:{} for x in nums}
2021
n = len(nums)
@@ -34,4 +35,4 @@ def numSquarefulPerms(self, nums: List[int]) -> int:
3435
vis[i] = True
3536
self.makePermutation(1,vis,self.nums[i],n)
3637
vis[i] = False
37-
return self.ans
38+
return self.ans

0 commit comments

Comments
 (0)