当前位置:网站首页>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号
边栏推荐
- Mapper agent development
- Use redis to realize self increment serial number
- The difference between new and make in golang
- SQL advanced syntax
- The concepts of terminal voltage, phase voltage and line voltage in FOC vector control and BLDC control are still unclear
- php 获取真实ip
- Maybe you read a fake Tianlong eight
- Arduino - 字符判断函数
- [array] binary search
- Win11启用粘滞键关闭不了怎么办?粘滞键取消了但不管用怎么解决
猜你喜欢

Data set - fault diagnosis: various data and data description of bearings of Western Reserve University

基于Pyqt5工具栏按钮可实现界面切换-2

Catalogue of digital image processing experiments

Ideal car × Oceanbase: when the new forces of car building meet the new forces of database

一文掌握基于深度学习的人脸表情识别开发(基于PaddlePaddle)

JDBC教程

【Redis笔记】压缩列表(ziplist)

What experience is there only one test in the company? Listen to what they say

Pandora IOT development board learning (HAL Library) - Experiment 4 serial port communication experiment (learning notes)

程序分析与优化 - 9 附录 XLA的缓冲区指派
随机推荐
Dishes launcher small green program and directory management (efficiency tool)
Markdown basic grammar
采用VNC Viewer方式远程连接树莓派
数字图像处理实验目录
Alibaba cloud award winning experience: how to use polardb-x
Third party payment function test point [Hangzhou multi tester _ Wang Sir] [Hangzhou multi tester]
C# MVC创建一个视图摆脱布局的影响
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
JDBC教程
The use of 8255 interface chip and ADC0809
提交代码流程
golang入门:for...range修改切片中元素的值的另类方法
Submit code process
基于Pyqt5工具栏按钮可实现界面切换-1
高数有多难?AI 卷到数学圈,高数考试正确率 81%!
Convolution和Batch normalization的融合
[analysis of STL source code] imitation function (to be supplemented)
Simple square wave generating circuit [51 single chip microcomputer and 8253a]
C MVC creates a view to get rid of the influence of layout
vim区间删行注释