当前位置:网站首页>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号
边栏推荐
- Go basic constant definition and use
- Maybe you read a fake Tianlong eight
- 内网渗透 | 手把手教你如何进行内网渗透
- How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
- C MVC creates a view to get rid of the influence of layout
- Brief introduction to common sense of Zhongtai
- JDBC Exercise case
- CDN 加速,需要域名先备案
- SharedPreferences save list < bean > to local and solve com google. gson. internal. Linkedtreemap cannot be cast to exception
- C# MVC创建一个视图摆脱布局的影响
猜你喜欢
Compose 中的 'ViewPager' 详解 | 开发者说·DTalk
MySQL Foundation
Talk about memory model and memory order
Maybe you read a fake Tianlong eight
C# MVC创建一个视图摆脱布局的影响
理想汽车×OceanBase:当造车新势力遇上数据库新势力
Ideal car × Oceanbase: when the new forces of car building meet the new forces of database
Dishes launcher small green program and directory management (efficiency tool)
Print out mode of go
2022年最新最全软件测试面试题大全
随机推荐
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
Pandora IOT development board learning (HAL Library) - Experiment 3 key input experiment (learning notes)
ADC of stm32
Difference between NVIDIA n card and amda card
Dishes launcher small green program and directory management (efficiency tool)
php 获取真实ip
What if win11 can't turn off the sticky key? The sticky key is cancelled but it doesn't work. How to solve it
Detailed explanation of 'viewpager' in compose | developer said · dtalk
Which common ports should the server open
Solution: exceptiole 'xxxxx QRTZ_ Locks' doesn't exist and MySQL's my CNF file append lower_ case_ table_ Error message after names startup
JDBC练习案例
Convolution和Batch normalization的融合
MarkDown基本语法
JDBC practice cases
潘多拉 IOT 开发板学习(HAL 库)—— 实验4 串口通讯实验(学习笔记)
Temperature measurement and display of 51 single chip microcomputer [simulation]
20220527_ Database process_ Statement retention
Use redis to realize self increment serial number
Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
Writing of head and bottom components of non routing components