当前位置:网站首页>leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
leetcode 650. 2 Keys Keyboard 只有两个键的键盘(中等)
2022-07-02 22:29:00 【InfoQ】
一、题目大意
- 1 <= n <= 1000
二、解题思路
三、解题方法
3.1 Java实现
public class Solution {
public int minSteps(int n) {
int[] dp = new int[n + 1];
int h = n * n;
for (int i = 2; i <= n; i++) {
dp[i] = i;
for (int j = 2; j <= h; j++) {
if (i % j == 0) {
dp[i] = dp[j] + dp[i / j];
break;
}
}
}
return dp[n];
}
}
四、总结小记
- 2022/7/2 期待7月11号
边栏推荐
- LINQ usage collection in C #
- 【ML】李宏毅三:梯度下降&分类(高斯分布)
- 返回二叉树中最大的二叉搜索子树的根节点
- 提交代码流程
- 潘多拉 IOT 开发板学习(HAL 库)—— 实验4 串口通讯实验(学习笔记)
- Use the scroll bar of souI when using the real window in souI
- How does win11 turn on visual control? Win11 method of turning on visual control
- [redis notes] compressed list (ziplist)
- JSON data transfer parameters
- Load balancing cluster (LBC)
猜你喜欢

What if win11 can't turn off the sticky key? The sticky key is cancelled but it doesn't work. How to solve it

JDBC教程

潘多拉 IOT 开发板学习(HAL 库)—— 实验4 串口通讯实验(学习笔记)

跨境电商如何通过打好数据底座,实现低成本稳步增长

JSON data transfer parameters

2022 latest and complete interview questions for software testing

第三方支付功能测试点【杭州多测师_王sir】【杭州多测师】

Difference between NVIDIA n card and amda card

Convolution和Batch normalization的融合

RuntimeError: no valid convolution algorithms available in CuDNN
随机推荐
sourcetree 详细
【ML】李宏毅三:梯度下降&分类(高斯分布)
Speech recognition Series 1: speech recognition overview
Talk about memory model and memory order
Brief introduction to common sense of Zhongtai
How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
【直播预约】数据库OBCP认证全面升级公开课
【Redis笔记】压缩列表(ziplist)
(毒刺)利用Pystinger Socks4上线不出网主机
简述中台的常识
Dishes launcher small green program and directory management (efficiency tool)
Quantitative analysis of PSNR, SSIM and RMSE
[Verilog tutorial]
VIM interval deletion note
潘多拉 IOT 开发板学习(HAL 库)—— 实验4 串口通讯实验(学习笔记)
Implementation of VGA protocol based on FPGA
The difference between new and make in golang
I've been interviewed. The starting salary is 16K
Highly available cluster (HAC)
返回二叉树两个节点间的最大距离