From 3e99c03dd76f1dc78cf8a24e3e44aa10c78be77b Mon Sep 17 00:00:00 2001 From: yin-zh Date: Wed, 25 Aug 2021 11:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0src/main/java/com/yzh/RotateA?= =?UTF-8?q?rray.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yzh/RotateArray.java | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/yzh/RotateArray.java b/src/main/java/com/yzh/RotateArray.java index 5da3c5f..919ddf9 100644 --- a/src/main/java/com/yzh/RotateArray.java +++ b/src/main/java/com/yzh/RotateArray.java @@ -1,10 +1,29 @@ package com.yzh; +/** + * 要求通过前面所学的旋转数组算法:在不占用额外空间的条件下 将所给的数组中的元素向右移动k个位置,使用Java语言实现 + * 输入:给定数组 nums + * 移动距离 k + * 输出:移动k个位置后的数组 nums + */ public class RotateArray { - public void solution(int nums[],int k){ - - //请在下方编辑你的代码,如有需要请另写函数 + public int[] solution(int[] nums,int k){ + //请在下方编辑代码,可调用后面的数组翻转函数 + + + return nums; + } + /** + * 数组翻转函数:对数组的指定部分进行翻转 + * 输入:给定的数组 nums + * 翻转开始位置:start + * 翻转结束位置:end + */ + public void reverse(int[] nums, int start, int end) { + //请在下方编辑 数组翻转函数 + + } } } -- GitLab