650. 2 Keys Keyboard
2017-09-01 10:00
113 查看
比如说2为2次才能得到,那么4需要4次,6需要5次,8需要6次。
class Solution { public int minSteps(int n) { if(n==1)return 0; int[]dp= new int ; for (int i = 0; i < n; i++) { dp[i] = i+1; } for (int i=1;i<n;i++){ for (int j=2;j<=n/(i+1);j++) { dp[(i+1)*j-1] = Math.min(dp[i]+j,dp[(i+1)*j-1]); } } return dp[n-1]; } }
相关文章推荐
- 650. 2 Keys Keyboard【Medium】可能是数学题
- [LeetCode] 650. 2 Keys Keyboard 两键的键盘
- leetcode 650. 2 Keys Keyboard
- [LeetCode] 650. 2 Keys Keyboard
- LeetCode 650. 2 Keys Keyboard
- LeetCode650. 2 Keys Keyboard
- leetcode_650. 2 Keys Keyboard
- 650. 2 Keys Keyboard
- [LeetCode] 650. 2 Keys Keyboard
- leetcode 650. 2 Keys Keyboard
- LeetCode -- 650. 2 Keys Keyboard
- Leetcode: 650. 2 Keys Keyboard
- Leetcode 650. 2 Keys Keyboard[medium]
- LeetCode650. 2 Keys Keyboard
- LeetCode | 650. 2 Keys Keyboard 数学原理题分析
- Leetcode 650. 2 Keys Keyboard 2指键盘 解题报告
- 650. 2 Keys Keyboard
- 650. 2 Keys Keyboard
- LeetCode 650. 2 Keys Keyboard--动态规划
- Leetcode 650. 2 Keys Keyboard