Skip to content

Commit a6f00ea

Browse files
committed
Update count-of-smaller-numbers-after-self.py
1 parent 5e4ae4a commit a6f00ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python/count-of-smaller-numbers-after-self.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def query(self, i):
4848
i -= (i & -i)
4949
return ret
5050

51-
sorted_nums, nth_smallest = sorted(nums), [0] * len(nums)
51+
sorted_nums, orderings = sorted(nums), [0] * len(nums)
5252
for i, num in enumerate(nums):
53-
nth_smallest[i] = binarySearch(sorted_nums, num, lambda x, y: x <= y)
53+
orderings[i] = binarySearch(sorted_nums, num, lambda x, y: x <= y)
5454

5555
ans, bit= [0] * len(nums), BIT(len(nums) + 1)
5656
for i in reversed(xrange(len(nums))):
57-
ans[i] = bit.query(nth_smallest[i])
58-
bit.add(nth_smallest[i] + 1, 1)
57+
ans[i] = bit.query(orderings[i])
58+
bit.add(orderings[i] + 1, 1)
5959
return ans
6060

0 commit comments

Comments
 (0)