DAY16-T1342&面试题 05.08 -2022-01-31-非自己作答
class Solution:
def numberOfSteps(self, num: int) -> int:
ans = 0
while num:
ans += num & 1
if num > 1:
ans += 1
num >>= 1
return ans
class Solution:
def findMaxValueOfEquation(self, points: List[List[int]], k: int) -> int:
max_count = float('-inf')
left = right = 0
while right < points.__len__():
if left >= right:
right += 1
continue
if points[right][0] - points[left][0] > k:
left += 1
continue
max_count = max(max_count, points[left][1] + points[right][1] + points[right][0] - points[left][0])
if points[right][1] - points[right][0] > points[left][1] - points[left][0]:
left += 1
continue
right += 1
return max_count