GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing leetcode.cn — 1217. 玩筹码 - 力扣(LeetCode) 题目描述 题目描述 题解 题解 提交记录 提交记录 简单 有 我们需要把所有筹码移到同一个位置。在一步中,我们可以将第
返回将所有筹码移动到同一位置上所需要的 最小代价 。
示例 1:
输入:position = [1,2,3] 输出:1 解释:第一步:将位置3的筹码移动到位置1,成本为0。 第二步:将位置2的筹码移动到位置1,成本= 1。 总成本是1。 示例 2:
输入:position = [2,2,2,3,3] 输出:2 解释:我们可以把位置3的两个筹码移到位置2。每一步的成本为1。总成本= 2。 示例 3: 输入:position = [1,1000000000] 输出:1
提示:
代码 代码 测试用例 测试用例 测试结果 测试结果 |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |