It's a lovely Saturday morning in Wisconsin, and I feel like writing a few words about Weekly Challenge 396 , which I finished earlier this week.
Task 1: Finishing Order
You are given two arrays of integers, @order and @friends . The @order array (size n ) contains every integer from 1 to n exactly once. The @friends array contains ID sorted in strictly increasing order. Write a script to return the array containing IDs in finishing order.
Example 1:
Input: @order = (3, 1, 4, 2, 5) @friends = (1, 2, 4)
Output: (1, 4, 2)
ID 1 finished 2nd, ID 4 finished 3rd, ID 2 finished 4th.
Example 2:
_Input: @order = (5, 4, 3, 2, 1) @friends = (1, 3, 5)
Output: (5, 3, 1)
ID 5 finished 1st, ID 3 finished 3rd, ID 1 finished 5th.
Example 3:
Input: @order = (2, 4, 1, 3) @friends = (1, 2, 3, 4)
Output: (2, 4, 1, 3)
ID 2 finished 1st, ID 4 finished 2nd, ID 1 finished 3rd, ID 3 finished 4th.
Example 4:
Input: @order = (4, 1, 3, 2) @friends = (3)
Output: (3)
Example 5:
Input: @order = (1, 3, 2, 6, 5, 4)…