From c68c1e3fd0859bac732ed308074fe77394af7a0e Mon Sep 17 00:00:00 2001 From: sagnikc395 Date: Mon, 8 May 2023 12:40:23 +0530 Subject: [PATCH] added solution for concatenation of array, p1929 --- javascript/1929-Concatenation-of-Array.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 javascript/1929-Concatenation-of-Array.js diff --git a/javascript/1929-Concatenation-of-Array.js b/javascript/1929-Concatenation-of-Array.js new file mode 100644 index 000000000..a7007d22f --- /dev/null +++ b/javascript/1929-Concatenation-of-Array.js @@ -0,0 +1,13 @@ +//https://leetcode.com/problems/concatenation-of-array/description/ + +/** + * @param {number[]} nums + * @return {number[]} + */ +var getConcatenation = function (nums) { + let res = []; + for (let i = 0; i < nums.length * 2; i++) { + res.push(nums[i % nums.length]); + } + return res; +};