Re: [闲聊] 每日LeetCode

楼主: Rushia (みけねこ的鼻屎)   2023-02-06 13:35:12
1470. Shuffle the Array
给你一个阵列和一个数字n,阵列有2n个元素,若阵列为:[x1,x2,...,xn,y1,y2,...,yn]
,返回如右形式的阵列:[x1,y1,x2,y2,...,xn,yn]。
Example:
Input: nums = [2,5,1,3,4,7], n = 3
Output: [2,3,5,4,1,7]
Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is
[2,3,5,4,1,7].
Input: nums = [1,2,3,4,4,3,2,1], n = 4
Output: [1,4,2,3,3,2,4,1]
思路:
1.按照题目的要求把元素一个一个放进阵列就好
JavaCode:
作者: sustainer123 (caster)   2023-02-06 13:40:00
大师
作者: ILoveIroha (一色 いろは)   2023-02-06 13:40:00
大师
作者: abcd991276 (QQ)   2023-02-06 14:36:00
大师

Links booklink

Contact Us: admin [ a t ] ucptt.com