当前位置:网站首页>Leetcode 279. Carré parfait carré complet (moyen)
Leetcode 279. Carré parfait carré complet (moyen)
2022-06-22 00:26:00 【InfoQ】
Un.、Objet
2.、Comment résoudre le problème
Trois、Comment résoudre le problème
3.1 JavaRéalisation
class Solution {
public int numSquares(int n) {
// Trouver moins quenLe carré complet de
List<Integer> squares = new ArrayList<>();
for (int i = 1; i < n + 1; i++) {
int tmp = i * i;
if (tmp < n + 1) {
squares.add(tmp);
} else {
break;
}
}
int[] dp = new int[n + 1];
for (int i = 1; i < n + 1; i++) {
dp[i] = Integer.MAX_VALUE;
}
for (int i = 1; i < n + 1; i++) {
for (int square : squares) {
if (i < square) {
break;
}
dp[i] = Math.min(dp[i], dp[i - square] + 1);
}
}
return dp[n];
}
}
Quatre、Résumé des notes
- 2022/6/21 Une fois par jour leetcode,Prenez l'habitude
边栏推荐
- [next] the component definition is missing display name in the next JS package
- 汇编语言范例
- Meet webassembly again
- [Yugong series] general responsibility allocation principle in June 2022 (IX) - principle of protected variables
- If a programmer goes to prison, will he be assigned to write code?
- Overview of embedded system and embedded design software
- 【微信小程序】微信小程序使用弹出框多级联动(示例)
- 重载和重写的区别
- [GXYCTF2019]SXMgdGhpcyBiYXNlPw==
- Detailed explanation of IDA static reverse analysis tool
猜你喜欢
![[ACTF新生赛2020]swp](/img/80/9fe85ee614857c5800c0d0b1ba9a3d.png)
[ACTF新生赛2020]swp

Recruitment brochure for traditional product manager international qualification certification (NPDP) in the second half of 2022

汇编语言范例

你有一个机会,这里有一个舞台

Buuctf misc Xiaoyi USB flash disk
![Xshell can only input the public key solution [personal test] when connecting to the virtual machine](/img/a9/2c315f92cef46976353b52fb1d0fba.png)
Xshell can only input the public key solution [personal test] when connecting to the virtual machine
![[wechat applet] 40029 invalid code solution set](/img/6f/05e82e8bb1e782ddedd7d009e8d88f.png)
[wechat applet] 40029 invalid code solution set

再次认识 WebAssembly

buuctf misc zip

火线沙龙第26期-多云安全专场
随机推荐
程序员坐牢了,会被安排去写代码吗?
All kinds of FPN in object detection
【愚公系列】2022年06月 通用职责分配原则(九)-受保护变量原则
Win10使用用户初始密码,连接Win Server失败
Importance of data governance
关于 NFT 和版权的纠结真相
Introduction to some code static checking tools
【微信小程序】40029 invalid code解决办法集合
Cloud whale took the lead in arranging door-to-door services to see how it broke through the industry "blockade" with services
[Yugong series] general responsibility allocation principle in June 2022 (IX) - principle of protected variables
SQL interview questions: top 15 questions in 2022
如何使用tensorboard add_histogram
Katalon recoder common commands
Qt之自制MP3播放器
【next】nextjs打包后出现passHref is missing
Store API memo
微博关闭发布多个兼职诈骗信息违规账号:如何打击数据造假灰产
如何优雅的统计代码耗时
rabbit:do_ run_ postlaunch_ phase/0 line 932
Based on asp Net development of enterprise communication source text message management platform source code