当前位置:网站首页>2022.7.20-----leetcode.1260
2022.7.20-----leetcode.1260
2022-07-21 07:57:00 【路Lu727】
public List<List<Integer>> shiftGrid(int[][] grid, int k) {
//一维化设置起点
int m=grid.length;
int n=grid[0].length;
int[] num=new int[m*n];
int idx=0;
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
num[idx++]=grid[i][j];
}
}
idx=m*n-k%(m*n);
List<List<Integer>> ans=new ArrayList<>();
for(int i=0;i<m;i++){
List<Integer> l=new ArrayList<>();
for(int j=0;j<n;j++){
l.add(num[(idx++)%(m*n)]);
}
ans.add(l);
}
return ans;
}
边栏推荐
- rust学习笔记-rust语言基础
- 零基础转行软件测试学习要不要报培训班学习,还是自学好?
- go gorm mysql报错:Error 1292: Incorrect datetime value: ‘XXX‘ for column ‘created_at‘ at row 1
- swift 【block】
- 06-1. Friends, initialization list initialization, Nei 'Bu
- Framework - WindowManager (window management service) practice of WMS
- Mysql05(视图)
- AidLux
- [Yugong series] go teaching course in July 2022 014 arithmetic operators of operators
- PYQT5打包出错,缺少文件,例ImportError: OpenCV loader: missing configuration file: [‘config.py‘]. Check
猜你喜欢
音频自动增益控制 AGC 解决的问题及原理解析
【扩展程序——猫抓1.0.15_网上的视频音频获取神器_安装教程加获取】
StarkNet如何改变L2格局?
项目实战四 图像拼接
数据库事务隔离级别
"I gave up programming and wrote a 1.3 million word hard science fiction."
【集训DAY9】Rotato【暴力】【思维】
When Lenovo Xiaoxin Air13 Pro reinstalls win10, the storage device driver cannot be found
记一次远程Debug调试Minecraft服务器插件经历
C language classic 100 questions (1-10 questions) (including answers)
随机推荐
Codeforces Round #805 A-F题解
First knowledge of loop and branch statements in C language
PYQT5打包出错,缺少文件,例ImportError: OpenCV loader: missing configuration file: [‘config.py‘]. Check
English语法_指示代词 this / these / that / those
Interrupt vector table in stm32
每个博主都需要问自己的7个基本问题
部署服务器
MongoDB 中的管道操作符($group、$unwind、$sort、$limit、$skip)
XMLDecoder解析流程分析
Learn the necessary tools of automation selenium think about automated testing in the pit again
The second financial article failed
Advanced C language: data storage (deep analysis - integer)
Basic usage of Networkx
Mysql04 (special train)
Visualization: you must know these ten data visualization tool software platforms
【集训DAY8】Interesting Number 【数位DP】
Mysql07 (data update DML)
Mysql07(数据更新DML)
【sciter】:窗口通信
06-1. Friends, initialization list initialization, Nei 'Bu