当前位置:网站首页>leetcode 650. 2 keys keyboard with only two keys (medium)
leetcode 650. 2 keys keyboard with only two keys (medium)
2022-07-02 23:40:00 【InfoQ】
One 、 The main idea of the topic
- 1 <= n <= 1000
Two 、 Their thinking
3、 ... and 、 How to solve the problem
3.1 Java Realization
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];
}
}
Four 、 Summary notes
- 2022/7/2 expect 7 month 11 Number
边栏推荐
- Flexible combination of applications is a false proposition that has existed for 40 years
- How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base
- Pandora IOT development board learning (HAL Library) - Experiment 4 serial port communication experiment (learning notes)
- Fudian bank completes the digital upgrade | oceanbase database helps to layout the distributed architecture of the middle office
- How difficult is it to be high? AI rolls into the mathematics circle, and the accuracy rate of advanced mathematics examination is 81%!
- Temperature measurement and display of 51 single chip microcomputer [simulation]
- Which common ports should the server open
- 基于Pyqt5工具栏按钮可实现界面切换-2
- Third party payment function test point [Hangzhou multi tester _ Wang Sir] [Hangzhou multi tester]
- 面试过了,起薪16k
猜你喜欢

LINQ usage collection in C #

MySQL Foundation

采用VNC Viewer方式远程连接树莓派

How can cross-border e-commerce achieve low-cost and steady growth by laying a good data base

What can I do after buying a domain name?

Bean加载控制

Flexible combination of applications is a false proposition that has existed for 40 years

【STL源码剖析】仿函数(待补充)

Maybe you read a fake Tianlong eight
![Eight bit responder [51 single chip microcomputer]](/img/4f/683948fca93a0dc1a0409839f60759.jpg)
Eight bit responder [51 single chip microcomputer]
随机推荐
ADC of stm32
(毒刺)利用Pystinger Socks4上线不出网主机
Fusion de la conversion et de la normalisation des lots
[ml] Li Hongyi III: gradient descent & Classification (Gaussian distribution)
How to maintain the brand influence of clothing enterprises
[live broadcast appointment] database obcp certification comprehensive upgrade open class
golang中new与make的区别
基于FPGA的VGA协议实现
[redis notes] compressed list (ziplist)
JSON data transfer parameters
BBR encounters cubic
富滇银行完成数字化升级|OceanBase数据库助力布局分布式架构中台
[array] binary search
What is the official website address of e-mail? Explanation of the login entry of the official website address of enterprise e-mail
数据集-故障诊断:西储大学轴承的各项数据以及数据说明
MarkDown基本语法
RuntimeError: no valid convolution algorithms available in CuDNN
Pandora IOT development board learning (HAL Library) - Experiment 3 key input experiment (learning notes)
解决:exceptiole ‘xxxxx.QRTZ_LOCKS‘ doesn‘t exist以及mysql的my.cnf文件追加lower_case_table_names后启动报错
Eight honors and eight disgraces of the programmer version~