Skip to content

Commit 094782f

Browse files
committed
Add solution #1920
1 parent b2035f2 commit 094782f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
1672|[Richest Customer Wealth](./1672-richest-customer-wealth.js)|Easy|
213213
1780|[Check if Number is a Sum of Powers of Three](./1780-check-if-number-is-a-sum-of-powers-of-three.js)|Medium|
214214
1880|[Check if Word Equals Summation of Two Words](./1880-check-if-word-equals-summation-of-two-words.js)|Easy|
215+
1920|[Build Array from Permutation](./1920-build-array-from-permutation.js)|Easy|
215216
1929|[Concatenation of Array](./1929-concatenation-of-array.js)|Easy|
216217
1935|[Maximum Number of Words You Can Type](./1935-maximum-number-of-words-you-can-type.js)|Easy|
217218
1996|[The Number of Weak Characters in the Game](./1996-the-number-of-weak-characters-in-the-game.js)|Medium|
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* 1920. Build Array from Permutation
3+
* https://leetcode.com/problems/build-array-from-permutation/
4+
* Difficulty: Easy
5+
*
6+
* Given a zero-based permutation nums (0-indexed), build an array ans of the same length
7+
* where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
8+
*
9+
* A zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1
10+
* (inclusive).
11+
*/
12+
13+
/**
14+
* @param {number[]} nums
15+
* @return {number[]}
16+
*/
17+
var buildArray = function(nums) {
18+
return nums.map(n => nums[n]);
19+
};

0 commit comments

Comments
 (0)