Description

To practice social distancing, every person who enters and exits the conference room must record their name in list. In no case does one enter and leave the room at the same time, and we do not record the enter/exit times.

Today there were n people that entered and exited the room. For the sake of convenience, the people who used the room are numbered from 1 through n, and nobody entered the room more than once. We are trying to find out how many people each person has encountered in the room.

For example, if the entrance order on the list is [1, 3, 2], and the exit order on the list is [1, 2, 3],

  • We do not know if 1 and 2 have met.
  • We do not know if 1 and 3 have met.
  • We are certain that 2 and 3 have met.

As another example, if the entrance order is [1, 4, 2, 3], and the exit order is [2, 1, 3, 4],

  • We are certain that 1 and 2 have met.
  • We do not know if 1 and 3 have met.
  • We are certain that 1 and 4 have met.
  • We do not know if 2 and 3 have met.
  • We are certain that 2 and 4 have met.
  • We are certain that 3 and 4 have met.

If 'enter', an array of integers containing the order of persons entering the room, and 'leave', an array of integers containing the order of persons exiting the room, are given as parameters, create a function 'solution' to return the number of people each person has encountered in numerical order of the person's number.


Restrictions
  • 1 ≤ Length of enter ≤ 1,000
  • 1 ≤ Elements of enter ≤ Length of enter
    • Each person's numbers are included once.
  • Length of leave = Length of enter
  • 1 ≤ Elements of leave ≤ Length of leave
    • Each person's numbers are included once.

Example
enter leave result
[1,3,2] [1,2,3] [0,1,1]
[1,4,2,3] [2,1,3,4] [2,2,1,3]
[3,2,1] [2,1,3] [1,1,2]
[3,2,1] [1,3,2] [2,2,2]
[1,4,2,3] [2,1,4,3] [2,2,0,2]

Explanation

Example #1

If they enter or leave the conference room as follows

conference room enter/leave
[1] #1 enters
[1, 3] #3 enters
[3] #1 leaves
[2, 3] #2 enters
[3] #2 leaves
[] #3 leaves
  • 1 and 2 have not met.
  • 1 and 3 have met.
  • 2 and 3 have met.

If they enter or leave the conference room as follows

conference room enter/leave
[1] #1 enters
[] #1 leaves
[3] #3 enters
[2, 3] #2 enters
[3] #2 leaves
[] #3 leaves
  • 1 and 2 have not met.
  • 1 and 3 have not met.
  • 2 and 3 have met.

Other than the method above, there are other ways to arrange the order so that 1 and 2 may meet. However, there is no way to prevent 2 and 3 from meeting.

Therefore

  • We do not know if 1 and 2 have met.
  • We do not know if 1 and 3 have met.
  • We are certain that 2 and 3 have met.

Example #2

Same as the example in the problem.

Example #3

  • We do not know if 1 and 2 have met.
  • We are certain that 1 and 3 have met.
  • We are certain that 2 and 3 have met.

Example #4

  • We are certain that 1 and 2 have met.
  • We are certain that 1 and 3 have met.
  • We are certain that 2 and 3 have met.

Example #5

  • We are certain that 1 and 2 have met.
  • We do not know if 1 and 3 have met.
  • We are certain that 1 and 4 have met.
  • We do not know if 2 and 3 have met.
  • We are certain that 2 and 4 have met.
  • We do not know if 3 and 4 have met.
Result Stop
Result of [Run] or [Submit] will be displayed here