cswork / OAOpen practice workspace

FactSetOA #3

Photo Album

Estimated HardStatement and editorial — judging is being prepared

Topics (AI-labelled)Prefix & RangesBinary Search

There is a collection of photos to place into an empty photo album, one at a time by order of importance. Each time a photo is inserted, all subsequent photos are shifted toward the right by one position. Given the id's of the photos and the positions where each should be placed, find out the sequence of the photos in the album after all photos have been inserted. Function Description Complete the function photoAlbum in the editor. photoAlbum has the following parameter(s):

  • int index[n]: the positions where the photos are to be inserted
  • int identity[n]: the photograph id numbers Returns int[n]: the sequence of identity values after all are inserted Input Format For Custom Testing The first line contains an integer, n, the number of elements in the array index. Each line i of the n subsequent lines (where 0 ≤ i The next line contains an integer, n, the number of elements in the array identity. Each line i of the n subsequent lines (where 0 ≤ i < n) contains an integer, identity[i].

Constraints

  • 1 ≤ n ≤ 2 x 10⁵
  • 0 ≤ index[i], identity[i] < n (0 ≤ i < n)

Editorial

Loading solution…