当前位置:网站首页>62. the last number left in the circle
62. the last number left in the circle
2022-06-12 05:18:00 【Be your goat】
The finger of the sword Offer 62. The last number in the circle
Ideas : mathematics
[0,1,2,3,4]
Delete the... Every time m Number , Back to :
Fourth Backstepping : Fill up m A place , Current array size on module 2
The third thrust : Fill up m A place , Current array size on module
…
summary , Namely (index+m)% Current array size
class Solution {
public:
int lastRemaining(int n, int m) {
int res=0;
for(int i=2;i<=n;++i){
res=(res+m)%i;
}
return res;
}
};
Time complexity O(n)
Spatial complexity O(1)
边栏推荐
- 12.24 day exercise -- Programming summation, 99 multiplication table, while loop and for loop exercises
- Detailed analysis of the 2021 central China Cup Title A (color selection of mosaic tiles)
- Some problems of silly girl solved
- Object class not ended
- ShanMeng and Beijing Adoption Day start NFT digital collection public offering
- IC验证中的force/release 学习整理(6)研究对 wire 类型信号的影响
- Minigui3 runs on Hisilicon hi3520d/hi3531 platform
- [backtracking] backtracking method to solve combinatorial problems
- Detailed tutorial on the use of yolov5 and training your own dataset with yolov5
- Google reinforcement learning framework seed RL environment deployment
猜你喜欢

Computer network connected but unable to access the Internet

Interview must ask: summary of ten classic sorting algorithms

【cjson】根节点注意事项

4.3 模拟浏览器操作和页面等待(显示等待和隐式等待、句柄)

asp. Net core theme Middleware

Main business objects of pupanvr record (5)

How to generate provincial data from county-level data in ArcGIS?

Summary of common interview questions in redis

Longest palindrome string
![[cjson] precautions for root node](/img/6c/4462bc8126935f00a5c64f18de13ea.png)
[cjson] precautions for root node
随机推荐
Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution
1007- stair climbing
Surface net radiation flux data, solar radiation data, rainfall data, air temperature data, sunshine duration, water vapor pressure distribution, wind speed and direction data, surface temperature
Main business objects of pupanvr record (5)
Thingsboard create RCP widget
4.3 simulate browser operation and page waiting (display waiting and implicit waiting, handle)
Shandong University network security range experimental platform -- team and project introduction
Acquisition of Lai data, NPP data, GPP data and vegetation coverage data
Normalized vegetation index (NDVI) data, NPP data, GPP data, evapotranspiration data, vegetation type data, ecosystem type distribution data
[backtracking] backtracking to solve subset problems
Pupanvr- establishment of development environment and diary, addition of some basic tool functions (3)
WiFi smartconfig implementation
Spatial distribution data of national multi-year average precipitation 1951-2021, temperature distribution data, evapotranspiration data, evaporation data, solar radiation data, sunshine data and wind
What is reverse repurchase of treasury bonds? Is the reverse repurchase of treasury bonds safe?
A complete set of installation procedures (for learning and communication only)
Quickly get PCA (principal component analysis) (principle code case)
ShanMeng and Beijing Adoption Day start NFT digital collection public offering
Uview customer management JS
Enhanced vegetation index evi, NDVI data, NPP data, GPP data, land use data, vegetation type data, rainfall data
Computer network connected but unable to access the Internet