Skip to content

Commit 6a6ffec

Browse files
authored
Update number-of-unequal-triplets-in-array.py
1 parent 3bef48f commit 6a6ffec

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/number-of-unequal-triplets-in-array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def unequalTriplets(self, nums):
1515
cnt = collections.Counter()
1616
dp = [0]*K # dp[i]: number of unequal (i+1)-plets
1717
for x in nums:
18+
cnt[x] += 1
1819
other_cnt = 1
1920
for i in xrange(K):
2021
dp[i] = dp[i]+other_cnt
21-
other_cnt = dp[i]-(cnt[x]+1)*other_cnt
22-
cnt[x] += 1
22+
other_cnt = dp[i]-cnt[x]*other_cnt
2323
return dp[K-1]

0 commit comments

Comments
 (0)