Pick Items
Return a list of the items of arr found at the indexes listed in positions, in the order of positions. An index may be listed more than once. Hint: NumPy lets you index an array with another array.
Example 1
arr [10,20,30,40]
positions [3,0,3]
returns [40,10,40]
Index 3 is 40, index 0 is 10, and 40 again.
Constraints
1 <= len(arr) <= 50- Every position is a valid index, and
positionsis not empty
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Price With TaxBeginner
- Range of ReadingsBeginner
- Recent AverageBeginner
- Running TotalBeginner
- Same PositionsBeginner
- Shopping TotalBeginner
- Side by Side ColumnsBeginner
- Sign of EachBeginner