fix(posts): fetch daily from files
This commit is contained in:
parent
3d2ee97afe
commit
2bcc3f4675
9 changed files with 691 additions and 0 deletions
11
public/code/algorithms/leetcode-daily/cfps-naive.py
Normal file
11
public/code/algorithms/leetcode-daily/cfps-naive.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
def countFairPairs(self, nums, lower, upper):
|
||||
nums.sort()
|
||||
ans = 0
|
||||
|
||||
for i, num in enumerate(nums):
|
||||
k = bisect_left(nums, lower - num, 0, i)
|
||||
j = bisect_right(nums, upper - num, 0, i)
|
||||
|
||||
ans += k - j
|
||||
|
||||
return ans
|
||||
Loading…
Add table
Add a link
Reference in a new issue