当前位置:网站首页>279. perfect square
279. perfect square
2022-06-12 18:17:00 【qq_ forty-eight million two hundred and thirty thousand four hu】
Give you an integer n , return And for n The minimum number of complete squares of .
Complete square It's an integer , Its value is equal to the square of another integer ; let me put it another way , Its value is equal to the product of the self multiplication of an integer . for example ,1、4、9 and 16 They're all perfect squares , and 3 and 11 No .
-------------------------------------------------------------------------------------------------------------------
Using dynamic planning and dual thinking for Cycle to solve 、
class Solution {
public int numSquares(int n) {
int[]res=new int[n+1];
for(int i=1;i<=n;i++){
int minn=Integer.MAX_VALUE;
for(int j=1;j*j<=i;j++){
minn=Math.min(minn,res[i-j*j]);
}
res[i]=minn+1;
}
return res[n];
}
}
边栏推荐
- Vant3+ts H5 pages are nested into apps to communicate with native apps
- Gospel of audio and video developers, rapid integration of AI dubbing capability
- The server time zone value ‘� й ��� ʱ ��‘ is unrecognized or represents more than one time zone. ......
- Write a select based concurrent server
- 网盘和对象云存储管理之磁盘映射工具比较
- Introduction to service grid and istio - continued
- torch.where的新用法(很老但是大家忽略的用法)
- Resttemplateconfig configuration print request response log under soringboot
- Gospel of audio and video developers, rapid integration of AI dubbing capability
- Small program +app, a low-cost and active technology combination idea
猜你喜欢

Explanation of core interrupt of Godson processor

VirtualLab basic experiment tutorial -6 Blazed grating

General differences between SQL server versions released by Microsoft in different periods so far, for reference

利用小程序快速生成App,只需七步

js两数之和

Write a select based concurrent server

VirtualLab basic experiment tutorial -5 Poisson bright spot

PHP:Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocat

C语言练习(4)——大数乘除

A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud
随机推荐
Explanation of core interrupt of Godson processor
Eve-ng installation (network device simulator)
JS dichotomy
Gossip about the source code of redis 89
ftrace
Office application cannot start normally 0xc0000142
leetcode151 翻转字符串里的单词
Nixos 22.05 installation process record
Introduction to reinforcement learning and analysis of classic items 1.3
Stream flow precautions
Machine learning series (5): Naive Bayes
网盘和对象云存储管理之磁盘映射工具比较
VirtualLab基础实验教程-6.闪耀光栅
VirtualLab basic experiment tutorial -4 Single slit diffraction
同花顺能开户吗,同花顺在APP上可以直接开通券商安全吗
C brief introduction
Gospel of audio and video developers, rapid integration of AI dubbing capability
JS中的栈(含leetcode例题)<持续更新~>
干货 | 一文搞定 pytest 自动化测试框架(二)
Summary of static memory allocation and dynamic memory allocation