当前位置: 首页 > news >正文

C语言 | Leetcode C语言题解之第189题轮转数组

题目:

题解:

void swap(int* a, int* b) {int t = *a;*a = *b, *b = t;
}void reverse(int* nums, int start, int end) {while (start < end) {swap(&nums[start], &nums[end]);start += 1;end -= 1;}
}void rotate(int* nums, int numsSize, int k) {k %= numsSize;reverse(nums, 0, numsSize - 1);reverse(nums, 0, k - 1);reverse(nums, k, numsSize - 1);
}
http://www.lryc.cn/news/383628.html

相关文章:

  • 【安全审核】音视频审核开通以及计费相关
  • 【实战】Spring Cloud Stream 3.1+整合Kafka
  • java之可变字符串之append方法
  • [保姆级教程]uniapp自定义导航栏
  • 项目训练营第二天
  • 考研数学一有多难?130+背后的残酷真相
  • vue2脚手架笔记总结1
  • 校园巡礼:一周只上四天课,入学即发钱?深圳理工大学,开局即王炸
  • 免交互 实验
  • Sublime Text 设置
  • spire.Pdf 将pdf转成image
  • 仓颉编程语言 -- 初识(一)
  • 前端JS必用工具【js-tool-big-box】学习,数值型数组的正向排序和倒向排序
  • python web框架哪家强?Flask、Django、FastAPI对比
  • Mybatis plus:IService接口
  • 时序分析基本概念介绍——min pulse width 最小脉冲宽度
  • PHP原生代码生成pdf---解决中文乱码问题
  • 智慧车库管理系统
  • 每日新闻掌握【2024年6月26日 星期三】
  • InVEST实践及在生态系统服务供需、固碳、城市热岛、论文写作等实际项目中应用
  • 慧科新闻搜索研究数据库的使用指南及个人获取途径
  • SpringBoot学习03-[Spring Boot与Web开发]
  • 数据恢复篇:如何恢复丢失的Android短信?
  • 数据结构历年考研真题对应知识点(栈)
  • BarTender版软件下载及安装教程
  • Python 中从字典中提取所有值到列表
  • Netty中Reactor线程的运行逻辑
  • liunx 搭建 zookeeper
  • selenium 3中等待方式
  • pytorch笔记:named_parameters