def count_purchase_plans(cake_prices, gift_prices, x):cake_prices.sortgift_prices.sortcount = 0left, right = 0, len(gift_prices) - 1# 使用双指针法统计满足条件的组合数目for cake in cake_prices:while right >= 0 and cake + gift_prices[right] > x:right -= 1if right摘要:def count_purchase_plans(cake_prices, gift_prices, x):cake_prices.sortgift_prices.sortcount = 0left, right = 0, len(gift_prices) -
来源:小雨课堂