问题描述
这是一个树状问题,其中,通过断开分支来进行分区,并通过在单独的分区中添加files_size来找到总文件大小。这些组合之间的差异最小。
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER_ARRAY parent
# 2. INTEGER_ARRAY files_size
#
def mostBalancedPartition(parent,files_size):
minimum = []
for i,j in zip(parent,parent[1:]):
if i == j:
num_1 = 0
num_2 = 0
for index_1,size in enumerate(files_size):
if index_1 > parent.index(i):
num_1 += size
else:
num_2 += size
minimum.append(abs(num_1 - num_2))
else:
pass
return min(tuple(minimum))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)