LeetCode1000.Minimum Cost to Merge Stones(合并石头的最低成本)

该博客详细介绍了LeetCode中的第1000题《Minimum Cost to Merge Stones》。这是一道难度为hard的问题,目标是找到合并所有石头成一堆的最小成本。文章提供了问题描述、难度等级、示例、注意点以及解题分析,并给出了动态规划的解决方案。
摘要由CSDN通过智能技术生成

1000.Minimum Cost to Merge Stones(合并石头的最低成本)

Description

There are N piles of stones arranged in a row. The i-th pile has stones[i] stones.

A move consists of merging exactly K consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these K piles.

Find the minimum cost to merge all piles of stones into one pile. If it is impossible, return

-1.


N 堆石头排成一排,第 i 堆中有 stones[i] 块石头。

每次移动(move)需要将连续的 K 堆石头合并为一堆,而这个移动的成本为这 K 堆石头的总数。

找出把所有石头合并成一堆的最低成本。如果不可能,返回 -1

题目链接:https://leetcode.com/problems/minimum-cost-to-merge-stones/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值