Re: [閒聊] 每日LeetCode

作者: abcd991276 (QQ)   2023-02-06 15:35:47
※ 引述《Rushia》之銘言
: 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:
:

Links booklink

Contact Us: admin [ a t ] ucptt.com