【发布时间】:2021-09-05 18:22:15
【问题描述】:
我知道有一个详尽的解决方案可以遍历每个数字,但是如何实现分而治之的方法呢?
使用不重复数字的整数数组和目标乘积整数,返回一组数字,其中包括乘积等于目标数字的所有对。
def product_pair(num_arr, product):
"""
:type num_arr: List[int]
:type product: int
:rtype: List[int]
"""
Example 1. Product_pair([3, 5, 9, 10, 23, 53], 20) => []
Example 2. Product_pair([10, 2, 9, 30, 5, 1], 10) => [10, 2, 5, 1]
【问题讨论】:
-
必须是pairs(即2个数字)还是还可以更多?
标签: python algorithm data-structures divide-and-conquer